private function generateMultipartIteratorFromFields(array $fields)
{
foreach ($fields as $key => $field) {
$fields[$key] = $field instanceof FileBody ? $field->getBody() : $field;
}
$promisor = new Deferred();
\Amp\all($fields)->when(function ($error, $result) use($promisor) {
if ($error) {
$promisor->fail($error);
} else {
$this->cachedBody = $result;
$promisor->succeed(new MultipartIterator($result));
}
});
return $promisor->promise();
}