summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Lib/Storage/AmazonS3.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 /apps/files_external/lib/Lib/Storage/AmazonS3.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 'apps/files_external/lib/Lib/Storage/AmazonS3.php')
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php9
1 files changed, 7 insertions, 2 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);