diff options
author | Adrian Brzezinski <adrian.brzezinski@eo.pl> | 2020-01-17 11:18:23 +0100 |
---|---|---|
committer | Adrian Brzezinski <adrian.brzezinski@eo.pl> | 2020-04-27 14:23:59 +0200 |
commit | e107519295fc11defbee37777adbdfba49faa7aa (patch) | |
tree | 7e1149ac1e0fb9e36b4f038f4ac807553229774b | |
parent | 2d7f71facaea2c7527db1d0e95fdf27e15be9d4d (diff) | |
download | nextcloud-server-e107519295fc11defbee37777adbdfba49faa7aa.tar.gz nextcloud-server-e107519295fc11defbee37777adbdfba49faa7aa.zip |
Large Object support for OpenStack Swift.
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>
-rw-r--r-- | lib/private/Files/ObjectStore/Swift.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php index 9a2aa82295e..33a8310fc9f 100644 --- a/lib/private/Files/ObjectStore/Swift.php +++ b/lib/private/Files/ObjectStore/Swift.php @@ -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 + ]); + } } /** |