diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-02-27 22:03:54 +0100 |
---|---|---|
committer | Backportbot <backportbot-noreply@rullzer.com> | 2019-03-06 14:34:15 +0000 |
commit | 30e790606e32df382d73a8a6301034c92afaf00d (patch) | |
tree | 5fa9a24eb7e24a8cee6fc4347783630ad045e67c | |
parent | 3acee4f1b4feed08fee973607a6eb49daecc48fb (diff) | |
download | nextcloud-server-30e790606e32df382d73a8a6301034c92afaf00d.tar.gz nextcloud-server-30e790606e32df382d73a8a6301034c92afaf00d.zip |
Use a tmp file for swift writes
Else this leads to a seekable stream error with chunked uploads
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r-- | lib/private/Files/ObjectStore/Swift.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php index 3d6bf9d69da..7e4654b6eb2 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) ]); } |