From 191a82e768157b5a95269dc80283b59e03212c56 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 22 Aug 2014 14:11:21 +0200 Subject: [PATCH] Stream downloads from Swift object stores without downloading it first --- lib/private/files/objectstore/swift.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/private/files/objectstore/swift.php b/lib/private/files/objectstore/swift.php index 3378fd7b86..1e8dd6a740 100644 --- a/lib/private/files/objectstore/swift.php +++ b/lib/private/files/objectstore/swift.php @@ -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; } /**