GDrive stream download with RetryWrapper
This commit is contained in:
parent
ed88f7b8b5
commit
99843c06f9
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue