diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index ee7a73836157..3e8b60d33df7 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -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 @@ 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;