From 1153123b90c7082723513f84243131860bbc649d Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 27 Feb 2019 22:03:54 +0100 Subject: [PATCH] Use a tmp file for swift writes Else this leads to a seekable stream error with chunked uploads Signed-off-by: Roeland Jago Douma --- lib/private/Files/ObjectStore/Swift.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php index 3d6bf9d69d..7e4654b6eb 100644 --- a/lib/private/Files/ObjectStore/Swift.php +++ b/lib/private/Files/ObjectStore/Swift.php @@ -76,9 +76,18 @@ class Swift implements IObjectStore { * @throws \Exception from openstack lib when something goes wrong */ public function writeObject($urn, $stream) { + $handle = $stream; + + $meta = stream_get_meta_data($stream); + if (!(isset($meta['seekable']) && $meta['seekable'] === true)) { + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('swiftwrite'); + file_put_contents($tmpFile, $stream); + $handle = fopen($tmpFile, 'rb'); + } + $this->getContainer()->createObject([ 'name' => $urn, - 'stream' => stream_for($stream) + 'stream' => stream_for($handle) ]); }