GDrive stream download with RetryWrapper

This commit is contained in:
Vincent Petry 2016-03-23 14:55:03 +01:00
parent 510e8db1ba
commit 7be541bda1
1 changed files with 5 additions and 4 deletions

View File

@ -35,6 +35,7 @@ namespace OC\Files\Storage;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use Icewind\Streams\IteratorDirectory; use Icewind\Streams\IteratorDirectory;
use Icewind\Streams\RetryWrapper;
set_include_path(get_include_path().PATH_SEPARATOR. set_include_path(get_include_path().PATH_SEPARATOR.
\OC_App::getAppPath('files_external').'/3rdparty/google-api-php-client/src'); \OC_App::getAppPath('files_external').'/3rdparty/google-api-php-client/src');
@ -441,10 +442,9 @@ class Google extends \OC\Files\Storage\Common {
// the library's service doesn't support streaming, so we use Guzzle instead // the library's service doesn't support streaming, so we use Guzzle instead
$client = \OC::$server->getHTTPClientService()->newClient(); $client = \OC::$server->getHTTPClientService()->newClient();
try { try {
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); $response = $client->get($downloadUrl, [
$client->get($downloadUrl, [
'headers' => $httpRequest->getRequestHeaders(), 'headers' => $httpRequest->getRequestHeaders(),
'save_to' => $tmpFile, 'stream' => true,
'verify' => __DIR__ . '/../3rdparty/google-api-php-client/src/Google/IO/cacerts.pem', 'verify' => __DIR__ . '/../3rdparty/google-api-php-client/src/Google/IO/cacerts.pem',
]); ]);
} catch (RequestException $e) { } catch (RequestException $e) {
@ -459,7 +459,8 @@ class Google extends \OC\Files\Storage\Common {
} }
} }
return fopen($tmpFile, 'r'); $handle = $response->getBody();
return RetryWrapper::wrap($handle);
} }
} }
return false; return false;