diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-05-06 13:03:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-06 13:03:24 +0200 |
commit | d5850eb28ff91a4f3faf004572dd541a20cb4fdb (patch) | |
tree | a7351f24182ffde863e49c6e0ebc65d9837ccbbb /lib | |
parent | 3bf4e7d673cbd8740a52426a7bfc40bb6287a2c2 (diff) | |
parent | e107519295fc11defbee37777adbdfba49faa7aa (diff) | |
download | nextcloud-server-d5850eb28ff91a4f3faf004572dd541a20cb4fdb.tar.gz nextcloud-server-d5850eb28ff91a4f3faf004572dd541a20cb4fdb.zip |
Merge pull request #18955 from adrb/swift_upload_large_objects
Large Object support for OpenStack Swift
Diffstat (limited to 'lib')
-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 1ce4312af2b..87347c3f71b 100644 --- a/lib/private/Files/ObjectStore/Swift.php +++ b/lib/private/Files/ObjectStore/Swift.php @@ -33,6 +33,8 @@ use OCP\Files\NotFoundException; use OCP\Files\ObjectStore\IObjectStore; use OCP\Files\StorageAuthException; +const SWIFT_SEGMENT_SIZE = 1073741824; // 1GB + class Swift implements IObjectStore { /** * @var array @@ -81,10 +83,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 + ]); + } } /** |