sink
摘要
声明响应的主体部分将要保存的位置。
类型
- string (path to file on disk)
fopen()
resourcePsr\Http\Message\StreamInterface
默认值
PHP temp stream
常量
GuzzleHttp\RequestOptions::SINK
传入字符串来指定将要保存响应主体内容的文件的路径:
$client->request('GET', '/stream/20', ['sink' => '/path/to/file']);
传入 fopen()
返回的资源将响应写入PHP流:
$resource = fopen('/path/to/file', 'w');
$client->request('GET', '/stream/20', ['sink' => $resource]);
传入 Psr\Http\Message\StreamInterface
对象将响应写入打开的PSR-7流。
$resource = fopen('/path/to/file', 'w');
$stream = GuzzleHttp\Psr7\stream_for($resource);
$client->request('GET', '/stream/20', ['save_to' => $stream]);