Skip to content

Allow MultipartStreamBuilder subclass to manipulate data #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/MultipartStreamBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ public function __construct($streamFactory = null)
}
}

/**
* Add a resource to the Multipart Stream
*
* @param string|resource|\Psr\Http\Message\StreamInterface $resource
* The filepath, resource or StreamInterface of the data.
* @param array $headers
* Additional headers array: ['header-name' => 'header-value'].
*
* @return MultipartStreamBuilder
*/
public function addData($resource, array $headers = [])
{
$stream = $this->createStream($resource);
$this->data[] = ['contents' => $stream, 'headers' => $headers];
return $this;
}

/**
* Add a resource to the Multipart Stream.
*
Expand Down