Skip to content

Commit

Permalink
GDrive stream download with RetryWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Petry committed Mar 30, 2016
1 parent 510e8db commit 7be541b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/files_external/lib/google.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

use GuzzleHttp\Exception\RequestException;
use Icewind\Streams\IteratorDirectory;
use Icewind\Streams\RetryWrapper;

set_include_path(get_include_path().PATH_SEPARATOR.
\OC_App::getAppPath('files_external').'/3rdparty/google-api-php-client/src');
Expand Down Expand Up @@ -441,10 +442,9 @@ public function fopen($path, $mode) {
// the library's service doesn't support streaming, so we use Guzzle instead
$client = \OC::$server->getHTTPClientService()->newClient();
try {
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
$client->get($downloadUrl, [
$response = $client->get($downloadUrl, [
'headers' => $httpRequest->getRequestHeaders(),
'save_to' => $tmpFile,
'stream' => true,
'verify' => __DIR__ . '/../3rdparty/google-api-php-client/src/Google/IO/cacerts.pem',
]);
} catch (RequestException $e) {
Expand All @@ -459,7 +459,8 @@ public function fopen($path, $mode) {
}
}

return fopen($tmpFile, 'r');
$handle = $response->getBody();
return RetryWrapper::wrap($handle);
}
}
return false;
Expand Down

0 comments on commit 7be541b

Please sign in to comment.