Skip to content

Commit

Permalink
Merge pull request #22604 from owncloud/fix-google-drive-encryption
Browse files Browse the repository at this point in the history
Copy into local file
  • Loading branch information
DeepDiver1975 committed Feb 25, 2016
2 parents 5ecf2d5 + aebb900 commit 202bf17
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions apps/files_external/lib/google.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

namespace OC\Files\Storage;

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

set_include_path(get_include_path().PATH_SEPARATOR.
Expand Down Expand Up @@ -439,19 +440,24 @@ public function fopen($path, $mode) {
// 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;
Expand Down

0 comments on commit 202bf17

Please sign in to comment.