summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2019-01-28 14:51:19 +0100
committerRobin Appelman <robin@icewind.nl>2019-01-28 14:51:19 +0100
commit1d322d3b375ff2e93c17e79efa619a20ec809f3d (patch)
tree78f421f50061ce60b074542a4f62935f54114f57 /tests/lib
parent2767139ca9107b0aff9cfba0e9c0674011bedece (diff)
downloadnextcloud-server-1d322d3b375ff2e93c17e79efa619a20ec809f3d.tar.gz
nextcloud-server-1d322d3b375ff2e93c17e79efa619a20ec809f3d.zip
always use multipart uploader for s3 uploads
the multipart uploader handles non seekable streams while `upload` does not Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Files/ObjectStore/S3Test.php31
1 files changed, 28 insertions, 3 deletions
diff --git a/tests/lib/Files/ObjectStore/S3Test.php b/tests/lib/Files/ObjectStore/S3Test.php
index a54ade8fd08..91b24d8b615 100644
--- a/tests/lib/Files/ObjectStore/S3Test.php
+++ b/tests/lib/Files/ObjectStore/S3Test.php
@@ -21,6 +21,7 @@
namespace Test\Files\ObjectStore;
+use Icewind\Streams\Wrapper;
use OC\Files\ObjectStore\S3;
class MultiPartUploadS3 extends S3 {
@@ -31,6 +32,30 @@ class MultiPartUploadS3 extends S3 {
}
}
+class NonSeekableStream extends Wrapper {
+ public static function wrap($source) {
+ $context = stream_context_create(array(
+ 'nonseek' => array(
+ 'source' => $source
+ )
+ ));
+ return Wrapper::wrapSource($source, $context, 'nonseek', self::class);
+ }
+
+ public function dir_opendir($path, $options) {
+ return false;
+ }
+
+ public function stream_open($path, $mode, $options, &$opened_path) {
+ $this->loadContext('nonseek');
+ return true;
+ }
+
+ public function stream_seek($offset, $whence = SEEK_SET) {
+ return false;
+ }
+}
+
/**
* @group PRIMARY-s3
*/
@@ -44,15 +69,15 @@ class S3Test extends ObjectStoreTest {
return new S3($config['arguments']);
}
- public function testMultiPartUploader() {
+ public function testUploadNonSeekable() {
$config = \OC::$server->getConfig()->getSystemValue('objectstore');
if (!is_array($config) || $config['class'] !== 'OC\\Files\\ObjectStore\\S3') {
$this->markTestSkipped('objectstore not configured for s3');
}
- $s3 = new MultiPartUploadS3($config['arguments']);
+ $s3 = $this->getInstance();
- $s3->writeObject('multiparttest', fopen(__FILE__, 'r'));
+ $s3->writeObject('multiparttest', NonSeekableStream::wrap(fopen(__FILE__, 'r')));
$result = $s3->readObject('multiparttest');