]> source.dussan.org Git - nextcloud-server.git/commitdiff
Stream downloads from Swift object stores without downloading it first
authorRobin Appelman <icewind@owncloud.com>
Fri, 22 Aug 2014 12:11:21 +0000 (14:11 +0200)
committerRobin Appelman <icewind@owncloud.com>
Fri, 22 Aug 2014 12:11:36 +0000 (14:11 +0200)
lib/private/files/objectstore/swift.php

index 3378fd7b86faa66712b456d19127c5b90a49e2a3..1e8dd6a740136dd777e3514eefa955b33f548e91 100644 (file)
@@ -120,12 +120,11 @@ class Swift implements IObjectStore {
                $objectContent = $object->getContent();
                $objectContent->rewind();
 
-               // directly returning the object stream does not work because the GC seems to collect it, so we need a copy
-               $tmpStream = fopen('php://temp', 'r+');
-               stream_copy_to_stream($objectContent->getStream(), $tmpStream);
-               rewind($tmpStream);
+               $stream = $objectContent->getStream();
+               // save the object content in the context of the stream to prevent it being gc'd until the stream is closed
+               stream_context_set_option($stream, 'swift','content', $objectContent);
 
-               return $tmpStream;
+               return $stream;
        }
 
        /**