diff options
author | Lukas Stabe <lukas@stabe.de> | 2020-01-22 09:45:41 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2020-04-01 15:21:01 +0200 |
commit | 14401efb0f6792415f15c92c1db07fe9e25ea466 (patch) | |
tree | c10154e544e282fb8dbeb7cc65341ec5a3b67f7e /lib/private/Files/ObjectStore/S3ObjectTrait.php | |
parent | c1368b86963b93a42ec98a856f8d307d922c8967 (diff) | |
download | nextcloud-server-14401efb0f6792415f15c92c1db07fe9e25ea466.tar.gz nextcloud-server-14401efb0f6792415f15c92c1db07fe9e25ea466.zip |
Enable fseek for files in S3 storage
Signed-off-by: Lukas Stabe <lukas@stabe.de>
Diffstat (limited to 'lib/private/Files/ObjectStore/S3ObjectTrait.php')
-rw-r--r-- | lib/private/Files/ObjectStore/S3ObjectTrait.php | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php index 6188357521b..1e9d095b9eb 100644 --- a/lib/private/Files/ObjectStore/S3ObjectTrait.php +++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php @@ -49,27 +49,16 @@ trait S3ObjectTrait { * @since 7.0.0 */ function readObject($urn) { - $client = $this->getConnection(); - $command = $client->getCommand('GetObject', [ - 'Bucket' => $this->bucket, - 'Key' => $urn + $context = stream_context_create([ + 's3seek' => [ + 'client' => $this->getConnection(), + 'bucket' => $this->bucket, + 'urn' => $urn, + ], ]); - $request = \Aws\serialize($command); - $headers = []; - foreach ($request->getHeaders() as $key => $values) { - foreach ($values as $value) { - $headers[] = "$key: $value"; - } - } - $opts = [ - 'http' => [ - 'protocol_version' => 1.1, - 'header' => $headers - ] - ]; - $context = stream_context_create($opts); - return fopen($request->getUri(), 'r', false, $context); + S3SeekableReadStream::registerIfNeeded(); + return fopen('s3seek://', 'r', false, $context); } /** |