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/apps
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-04-15 18:14:57 +0300
committerRobin Appelman <robin@icewind.nl>2021-04-21 16:25:58 +0300
commiteffb7dc8ba00c683e3b6717eaf1f358ce1c69b87 (patch)
tree6d9aa4d783242e56f2f971da6d74d05f66894d1e /apps
parentd2ea068552eb144d491b76e0a0ef8266144dcf45 (diff)
set mimetype for objects uploaded to object storages
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php9
-rw-r--r--apps/files_external/lib/Lib/Storage/Swift.php9
2 files changed, 14 insertions, 4 deletions
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 9ea278d7229..50bea958b6e 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -50,6 +50,7 @@ use OC\Files\Cache\CacheEntry;
use OC\Files\ObjectStore\S3ConnectionTrait;
use OC\Files\ObjectStore\S3ObjectTrait;
use OCP\Constants;
+use OCP\Files\IMimeTypeDetector;
class AmazonS3 extends \OC\Files\Storage\Common {
use S3ConnectionTrait;
@@ -68,12 +69,16 @@ class AmazonS3 extends \OC\Files\Storage\Common {
/** @var CappedMemoryCache|array */
private $filesCache;
+ /** @var IMimeTypeDetector */
+ private $mimeDetector;
+
public function __construct($parameters) {
parent::__construct($parameters);
$this->parseParams($parameters);
$this->objectCache = new CappedMemoryCache();
$this->directoryCache = new CappedMemoryCache();
$this->filesCache = new CappedMemoryCache();
+ $this->mimeDetector = \OC::$server->get(IMimeTypeDetector::class);
}
/**
@@ -573,7 +578,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
try {
if (!$this->file_exists($path)) {
- $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path);
+ $mimeType = $this->mimeDetector->detectPath($path);
$this->getConnection()->putObject([
'Bucket' => $this->bucket,
'Key' => $this->cleanKey($path),
@@ -684,7 +689,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
public function writeBack($tmpFile, $path) {
try {
$source = fopen($tmpFile, 'r');
- $this->writeObject($path, $source);
+ $this->writeObject($path, $source, $this->mimeDetector->detectPath($path));
$this->invalidateCache($path);
unlink($tmpFile);
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php
index f3381117469..5082816b2c2 100644
--- a/apps/files_external/lib/Lib/Storage/Swift.php
+++ b/apps/files_external/lib/Lib/Storage/Swift.php
@@ -47,6 +47,7 @@ use GuzzleHttp\Psr7\Uri;
use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\IteratorDirectory;
use OC\Files\ObjectStore\SwiftFactory;
+use OCP\Files\IMimeTypeDetector;
use OCP\Files\StorageBadConfigException;
use OCP\ILogger;
use OpenStack\Common\Error\BadResponseError;
@@ -76,6 +77,9 @@ class Swift extends \OC\Files\Storage\Common {
/** @var \OC\Files\ObjectStore\Swift */
private $objectStore;
+ /** @var IMimeTypeDetector */
+ private $mimeDetector;
+
/**
* Key value cache mapping path to data object. Maps path to
* \OpenCloud\OpenStack\ObjectStorage\Resource\DataObject for existing
@@ -205,6 +209,7 @@ class Swift extends \OC\Files\Storage\Common {
);
$this->objectStore = new \OC\Files\ObjectStore\Swift($this->params, $this->connectionFactory);
$this->bucket = $params['bucket'];
+ $this->mimeDetector = \OC::$server->get(IMimeTypeDetector::class);
}
public function mkdir($path) {
@@ -466,7 +471,7 @@ class Swift extends \OC\Files\Storage\Common {
}
return true;
} else {
- $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path);
+ $mimeType = $this->mimeDetector->detectPath($path);
$this->getContainer()->createObject([
'name' => $path,
'content' => '',
@@ -588,7 +593,7 @@ class Swift extends \OC\Files\Storage\Common {
public function writeBack($tmpFile, $path) {
$fileData = fopen($tmpFile, 'r');
- $this->objectStore->writeObject($path, $fileData);
+ $this->objectStore->writeObject($path, $fileData, $this->mimeDetector->detectPath($path));
// invalidate target object to force repopulation on fetch
$this->objectCache->remove($path);
unlink($tmpFile);