无法读取不可读的流

时间:2017-03-25 19:21:16

标签: php guzzle

我正在尝试使用guzzle下载外部文件。这是我使用的代码:

// $url is a URL I receive from Openload's API request
$url = 'https://abvzps.example.com/dl/l/4spxX_-cSO4/The+quick+brown+fox.mp4';
$path = storage_path('app/remote-uploads/test.mp4');

$client = new Client();
$client->get($url, ['sink' => $path]); 

代码可以从localhost上运行和下载,但是当我将它推送到生产环境时,我收到了这个错误:

[2017-03-25 19:08:06] production.ERROR: RuntimeException: Cannot read from non-readable stream in /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/psr7/src/Stream.php:208
Stack trace:
#0 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php(132): GuzzleHttp\Psr7\Stream->read(120)
#1 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php(105): GuzzleHttp\Exception\RequestException::getResponseBodySummary(Object(GuzzleHttp\Psr7\Response))
#2 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#3 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#4 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#5 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#6 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true)
#7 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#8 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#10 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#11 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/guzzle/src/Client.php(129): GuzzleHttp\Promise\Promise->wait()
...

我不太清楚如何解决这个问题,非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

如果没有真正的URL和调试,很难说些什么。

只需在异常之前设置断点并查看响应。 IMO应该包含错误,但我不知道,究竟是哪一个。