sink

摘要

声明响应的主体部分将要保存的位置。

类型

  • string (path to file on disk)
  • fopen() resource
  • Psr\Http\Message\StreamInterface

默认值

PHP temp stream

常量

GuzzleHttp\RequestOptions::SINK

传入字符串来指定将要保存响应主体内容的文件的路径:

  1. $client->request('GET', '/stream/20', ['sink' => '/path/to/file']);

传入 fopen() 返回的资源将响应写入PHP流:

  1. $resource = fopen('/path/to/file', 'w');
  2. $client->request('GET', '/stream/20', ['sink' => $resource]);

传入 Psr\Http\Message\StreamInterface 对象将响应写入打开的PSR-7流。

  1. $resource = fopen('/path/to/file', 'w');
  2. $stream = GuzzleHttp\Psr7\stream_for($resource);
  3. $client->request('GET', '/stream/20', ['save_to' => $stream]);