Merge pull request #22604 from owncloud/fix-google-drive-encryption

Copy into local file
This commit is contained in:
Thomas Müller 2016-02-25 14:35:39 +01:00
commit 202bf17e4a

View file

@ -33,6 +33,7 @@
namespace OC\Files\Storage;
use GuzzleHttp\Exception\RequestException;
use Icewind\Streams\IteratorDirectory;
set_include_path(get_include_path().PATH_SEPARATOR.
@ -439,19 +440,24 @@ class Google extends \OC\Files\Storage\Common {
// the library's service doesn't support streaming, so we use Guzzle instead
$client = \OC::$server->getHTTPClientService()->newClient();
try {
$response = $client->get($downloadUrl, [
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
$client->get($downloadUrl, [
'headers' => $httpRequest->getRequestHeaders(),
'stream' => true
'save_to' => $tmpFile,
]);
} catch (RequestException $e) {
if ($e->getResponse()->getStatusCode() === 404) {
return false;
if(!is_null($e->getResponse())) {
if ($e->getResponse()->getStatusCode() === 404) {
return false;
} else {
throw $e;
}
} else {
throw $e;
}
}
return $response->getBody();
return fopen($tmpFile, 'r');
}
}
return false;