diff --git a/lib/s3storage.php b/lib/s3storage.php index 39efc03d..bb21003e 100644 --- a/lib/s3storage.php +++ b/lib/s3storage.php @@ -67,7 +67,7 @@ public function __construct($params) { $this->params = $params; } - protected function init() { + protected function init(): void { if ($this->connection) { return; } @@ -178,7 +178,10 @@ public function deleteObject($urn) { public function readObject($urn) { $this->init(); try { - return \fopen($this->getUrl($urn), 'r'); + $context = stream_context_create([ + 'seekable' => true + ]); + return \fopen($this->getUrl($urn), 'rb', null, $context); } catch (AwsException $ex) { throw new ObjectStoreOperationException($ex->getAwsErrorMessage(), $ex->getStatusCode(), $ex); } @@ -275,7 +278,11 @@ public function getVersion($urn, $versionId) { public function getContentOfVersion($urn, $versionId) { $this->init(); try { - return \fopen($this->getUrl($urn, $versionId), 'r'); + $context = stream_context_create([ + 'seekable' => true + ]); + + return \fopen($this->getUrl($urn, $versionId), 'rb', null, $context); } catch (AwsException $ex) { throw new ObjectStoreOperationException($ex->getAwsErrorMessage(), $ex->getStatusCode(), $ex); }