diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-05-25 13:38:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-25 13:38:04 +0200 |
commit | 1d816add44fb0058d1fd927585a4e894c1d39132 (patch) | |
tree | c7cb8d854e318515d5a19fa8f832fb9b434f2530 /tests | |
parent | 4e8f72726ae7ede288cef5073527b6b7df737d88 (diff) | |
parent | 3d3ee1bfaefb16a5fe912932abff90bf972f3736 (diff) | |
download | nextcloud-server-1d816add44fb0058d1fd927585a4e894c1d39132.tar.gz nextcloud-server-1d816add44fb0058d1fd927585a4e894c1d39132.zip |
Merge pull request #20965 from nextcloud/backport/20033/stable18
[stable18] Enable fseek for files in S3 storage
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/ObjectStore/ObjectStoreTest.php | 2 | ||||
-rw-r--r-- | tests/lib/Files/ObjectStore/S3Test.php | 18 |
2 files changed, 18 insertions, 2 deletions
diff --git a/tests/lib/Files/ObjectStore/ObjectStoreTest.php b/tests/lib/Files/ObjectStore/ObjectStoreTest.php index 1383c0149a2..67c41eb7ccc 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreTest.php @@ -31,7 +31,7 @@ abstract class ObjectStoreTest extends TestCase { */ abstract protected function getInstance(); - private function stringToStream($data) { + protected function stringToStream($data) { $stream = fopen('php://temp', 'w+'); fwrite($stream, $data); rewind($stream); diff --git a/tests/lib/Files/ObjectStore/S3Test.php b/tests/lib/Files/ObjectStore/S3Test.php index 91b24d8b615..b3d65d9eff4 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, ]); } } @@ -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)); + } } |