]> source.dussan.org Git - nextcloud-server.git/commitdiff
Large Object support for OpenStack Swift. 18955/head
authorAdrian Brzezinski <adrian.brzezinski@eo.pl>
Fri, 17 Jan 2020 10:18:23 +0000 (11:18 +0100)
committerAdrian Brzezinski <adrian.brzezinski@eo.pl>
Mon, 27 Apr 2020 12:23:59 +0000 (14:23 +0200)
Until now, you wouldn't be able to create
objects larger that 5GB.

It's somewhat related with pull #18883

Signed-off-by: Adrian Brzezinski <adrian.brzezinski@eo.pl>
lib/private/Files/ObjectStore/Swift.php

index 9a2aa82295e8f8c4737d41270bb6a9d58f7fa5d0..33a8310fc9fa2023d4f642fd996a69c8b935f196 100644 (file)
@@ -32,6 +32,8 @@ use OCP\Files\ObjectStore\IObjectStore;
 use OCP\Files\StorageAuthException;
 use OpenStack\Common\Error\BadResponseError;
 
+const SWIFT_SEGMENT_SIZE = 1073741824; // 1GB
+
 class Swift implements IObjectStore {
        /**
         * @var array
@@ -80,10 +82,18 @@ class Swift implements IObjectStore {
                file_put_contents($tmpFile, $stream);
                $handle = fopen($tmpFile, 'rb');
 
-               $this->getContainer()->createObject([
-                       'name' => $urn,
-                       'stream' => stream_for($handle)
-               ]);
+               if (filesize($tmpFile) < SWIFT_SEGMENT_SIZE) {
+                       $this->getContainer()->createObject([
+                               'name' => $urn,
+                               'stream' => stream_for($handle)
+                       ]);
+               } else {
+                       $this->getContainer()->createLargeObject([
+                               'name' => $urn,
+                               'stream' => stream_for($handle),
+                               'segmentSize' => SWIFT_SEGMENT_SIZE
+                       ]);
+               }
        }
 
        /**