Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-05-06 14:03:24 +0300
committerGitHub <noreply@github.com>2020-05-06 14:03:24 +0300
commitd5850eb28ff91a4f3faf004572dd541a20cb4fdb (patch)
treea7351f24182ffde863e49c6e0ebc65d9837ccbbb /lib
parent3bf4e7d673cbd8740a52426a7bfc40bb6287a2c2 (diff)
parente107519295fc11defbee37777adbdfba49faa7aa (diff)
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.php18
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
+ ]);
+ }
}
/**