Merge pull request #14424 from nextcloud/fix/13554/swift_to_tmp
Use a tmp file for swift writes
This commit is contained in:
commit
1b27e9578d
1 changed files with 10 additions and 1 deletions
|
@ -76,9 +76,18 @@ class Swift implements IObjectStore {
|
||||||
* @throws \Exception from openstack lib when something goes wrong
|
* @throws \Exception from openstack lib when something goes wrong
|
||||||
*/
|
*/
|
||||||
public function writeObject($urn, $stream) {
|
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([
|
$this->getContainer()->createObject([
|
||||||
'name' => $urn,
|
'name' => $urn,
|
||||||
'stream' => stream_for($stream)
|
'stream' => stream_for($handle)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue