在laravel上使用Guzzle和Dropbox API下载文件

时间:2015-04-10 16:09:34

标签: laravel laravel-5 dropbox-api guzzle

我正在尝试创建一个可用于将指定文件下载到我的计算机上的本地文件夹的函数。请求是成功的,我确实收到了filedata,但是,我无法弄清楚如何提取并将其写入指定的路径。我该怎么办?

这是我的功能:

public function dropboxFileTransfer()
{
   $local = fopen('files/get.zip', 'r');

    $file = $this->client->get('https://api-content.dropbox.com/1/files/auto/dropbox-sdk-php-1.1.5.zip', [
        'headers' => [
            'Authorization' => 'Bearer ' . \Session::get('dtoken'),
        ],
    ]);

    $stream = Stream::factory($file->getBody()->__toString());

    $dest = Stream::factory($local);

    $dest->write($stream);

    return 'ok';
}

0 个答案:

没有答案