diff --git a/src/GoogleCloudStorage/GoogleCloudStorageAdapter.php b/src/GoogleCloudStorage/GoogleCloudStorageAdapter.php index b180f72b5..a8b1b5a03 100644 --- a/src/GoogleCloudStorage/GoogleCloudStorageAdapter.php +++ b/src/GoogleCloudStorage/GoogleCloudStorageAdapter.php @@ -60,7 +60,8 @@ public function __construct( string $prefix = '', ?VisibilityHandler $visibilityHandler = null, private string $defaultVisibility = Visibility::PRIVATE, - ?MimeTypeDetector $mimeTypeDetector = null + ?MimeTypeDetector $mimeTypeDetector = null, + private bool $streamReads = false, ) { $this->prefixer = new PathPrefixer($prefix); $this->visibilityHandler = $visibilityHandler ?? new PortableVisibilityHandler(); @@ -170,9 +171,13 @@ public function read(string $path): string public function readStream(string $path) { $prefixedPath = $this->prefixer->prefixPath($path); + $options = []; + if ($this->streamReads) { + $options['restOptions']['stream'] = true; + } try { - $stream = $this->bucket->object($prefixedPath)->downloadAsStream()->detach(); + $stream = $this->bucket->object($prefixedPath)->downloadAsStream($options)->detach(); } catch (Throwable $exception) { throw UnableToReadFile::fromLocation($path, $exception->getMessage(), $exception); }