Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
minor
  • Loading branch information
Nyholm committed Jul 14, 2016
commit 997c6a30317c48f0ce24b2af1a1cce339e3b33ec
15 changes: 7 additions & 8 deletions src/MultipartStreamBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MultipartStreamBuilder
private $boundary;

/**
* @var array array Element where each Element is an array with keys ['contents', 'headers', 'filename']
* @var array Element where each Element is an array with keys ['contents', 'headers', 'filename']
*/
private $data;

Expand Down Expand Up @@ -83,26 +83,25 @@ public function addResource($name, $resource, array $options)
* Build the stream.
*
* @return StreamInterface
* @throws \Exception
*/
public function build()
{
$streams = [];
foreach ($this->data as $name => $data) {
$streams = '';
foreach ($this->data as $data) {

// Add start and headers
$streams[] = "--{$this->getBoundary()}\r\n".
$streams .= "--{$this->getBoundary()}\r\n".
$this->getHeaders($data['headers'])."\r\n\r\n";

// Convert the stream to string
$streams[] = (string) $data['contents'];
$streams[] .= "\r\n";
$streams .= (string) $data['contents'];
$streams .= "\r\n";
}

// Append end
$streams[] = "--{$this->getBoundary()}--\r\n";

return $this->streamFactory->createStream(implode('', $streams));
return $this->streamFactory->createStream($streams);
}

/**
Expand Down