aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/ObjectStore/Swift.php
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-04-15 17:14:57 +0200
committerRobin Appelman <robin@icewind.nl>2021-04-21 15:25:58 +0200
commiteffb7dc8ba00c683e3b6717eaf1f358ce1c69b87 (patch)
tree6d9aa4d783242e56f2f971da6d74d05f66894d1e /lib/private/Files/ObjectStore/Swift.php
parentd2ea068552eb144d491b76e0a0ef8266144dcf45 (diff)
downloadnextcloud-server-effb7dc8ba00c683e3b6717eaf1f358ce1c69b87.tar.gz
nextcloud-server-effb7dc8ba00c683e3b6717eaf1f358ce1c69b87.zip
set mimetype for objects uploaded to object storages
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/ObjectStore/Swift.php')
-rw-r--r--lib/private/Files/ObjectStore/Swift.php9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/private/Files/ObjectStore/Swift.php b/lib/private/Files/ObjectStore/Swift.php
index 1b0888b0700..f9cccd0e205 100644
--- a/lib/private/Files/ObjectStore/Swift.php
+++ b/lib/private/Files/ObjectStore/Swift.php
@@ -74,12 +74,7 @@ class Swift implements IObjectStore {
return $this->params['container'];
}
- /**
- * @param string $urn the unified resource name used to identify the object
- * @param resource $stream stream with the data to write
- * @throws \Exception from openstack lib when something goes wrong
- */
- public function writeObject($urn, $stream) {
+ public function writeObject($urn, $stream, string $mimetype = null) {
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile('swiftwrite');
file_put_contents($tmpFile, $stream);
$handle = fopen($tmpFile, 'rb');
@@ -88,12 +83,14 @@ class Swift implements IObjectStore {
$this->getContainer()->createObject([
'name' => $urn,
'stream' => stream_for($handle),
+ 'contentType' => $mimetype,
]);
} else {
$this->getContainer()->createLargeObject([
'name' => $urn,
'stream' => stream_for($handle),
'segmentSize' => SWIFT_SEGMENT_SIZE,
+ 'contentType' => $mimetype,
]);
}
}