sink
Summary
Specify where the body of a response will be saved.
Types
- string (path to file on disk)
fopen()
resourcePsr\Http\Message\StreamInterface
Default
PHP temp stream
Constant
GuzzleHttp\RequestOptions::SINK
Pass a string to specify the path to a file that will store the contents of the response body:
$client->request('GET', '/stream/20', ['sink' => '/path/to/file']);
Pass a resource returned from fopen()
to write the response to a PHP stream:
$resource = fopen('/path/to/file', 'w');
$client->request('GET', '/stream/20', ['sink' => $resource]);
Pass a Psr\Http\Message\StreamInterface
object to stream the response body to an open PSR-7 stream.
$resource = fopen('/path/to/file', 'w');
$stream = GuzzleHttp\Psr7\stream_for($resource);
$client->request('GET', '/stream/20', ['save_to' => $stream]);
Note
The save_to
request option has been deprecated in favor of the sink
request option. Providing the save_to
option is now an alias of sink
.