|
|
|
|
@ -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);
|
|
|
|
|
|