Skip to content

Commit

Permalink
Merge pull request #522 from owncloud/feat/seekable-stream
Browse files Browse the repository at this point in the history
feat: create a seekable stream when reading. Allows http range reques…
  • Loading branch information
DeepDiver1975 authored Dec 29, 2021
2 parents 890e956 + 4413204 commit 44db53b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/s3storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function __construct($params) {
$this->params = $params;
}

protected function init() {
protected function init(): void {
if ($this->connection) {
return;
}
Expand Down Expand Up @@ -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([
's3' => ['seekable' => true]
]);
return \fopen($this->getUrl($urn), 'rb', false, $context);
} catch (AwsException $ex) {
throw new ObjectStoreOperationException($ex->getAwsErrorMessage(), $ex->getStatusCode(), $ex);
}
Expand Down Expand Up @@ -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([
's3' => ['seekable' => true]
]);

return \fopen($this->getUrl($urn, $versionId), 'rb', false, $context);
} catch (AwsException $ex) {
throw new ObjectStoreOperationException($ex->getAwsErrorMessage(), $ex->getStatusCode(), $ex);
}
Expand Down

0 comments on commit 44db53b

Please sign in to comment.