summaryrefslogtreecommitdiffstats
path: root/tests/lib/Files/ObjectStore/S3Test.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-04-06 21:38:49 +0200
committerGitHub <noreply@github.com>2020-04-06 21:38:49 +0200
commitf5919d5b830458c38747ab358805833ab29b6c9b (patch)
treec93736aeda037976da3d13d99178f354a1860635 /tests/lib/Files/ObjectStore/S3Test.php
parent5a82de14430f1645ab572b7c9ea25c2d1a49b3ba (diff)
parente22a28ecc2d5f03c28817b7d3cd263ed2f502c96 (diff)
downloadnextcloud-server-f5919d5b830458c38747ab358805833ab29b6c9b.tar.gz
nextcloud-server-f5919d5b830458c38747ab358805833ab29b6c9b.zip
Merge pull request #20033 from nextcloud/s3-seekable-stream
Enable fseek for files in S3 storage
Diffstat (limited to 'tests/lib/Files/ObjectStore/S3Test.php')
-rw-r--r--tests/lib/Files/ObjectStore/S3Test.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/tests/lib/Files/ObjectStore/S3Test.php b/tests/lib/Files/ObjectStore/S3Test.php
index b56978f4fee..525e020445a 100644
--- a/tests/lib/Files/ObjectStore/S3Test.php
+++ b/tests/lib/Files/ObjectStore/S3Test.php
@@ -27,7 +27,7 @@ use OC\Files\ObjectStore\S3;
class MultiPartUploadS3 extends S3 {
function writeObject($urn, $stream) {
$this->getConnection()->upload($this->bucket, $urn, $stream, 'private', [
- 'mup_threshold' => 1
+ 'mup_threshold' => 1,
]);
}
}
@@ -36,8 +36,8 @@ class NonSeekableStream extends Wrapper {
public static function wrap($source) {
$context = stream_context_create([
'nonseek' => [
- 'source' => $source
- ]
+ 'source' => $source,
+ ],
]);
return Wrapper::wrapSource($source, $context, 'nonseek', self::class);
}
@@ -83,4 +83,20 @@ class S3Test extends ObjectStoreTest {
$this->assertEquals(file_get_contents(__FILE__), stream_get_contents($result));
}
+
+ public function testSeek() {
+ $data = file_get_contents(__FILE__);
+
+ $instance = $this->getInstance();
+ $instance->writeObject('seek', $this->stringToStream($data));
+
+ $read = $instance->readObject('seek');
+ $this->assertEquals(substr($data, 0, 100), fread($read, 100));
+
+ fseek($read, 10);
+ $this->assertEquals(substr($data, 10, 100), fread($read, 100));
+
+ fseek($read, 100, SEEK_CUR);
+ $this->assertEquals(substr($data, 210, 100), fread($read, 100));
+ }
}