Merge pull request #7186 from nextcloud/s3-download-stream-fix-12

[12] Fix s3 download and touch
This commit is contained in:
Björn Schießle 2017-11-17 12:44:40 +01:00 committed by GitHub
commit 031bde5c88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -364,7 +364,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$fileId = $this->getCache()->put($path, $stat);
try {
//read an empty file from memory
$this->objectStore->writeObject($this->getURN($fileId), fopen('php://memory', 'r'));
$this->file_put_contents($path, ' ');
} catch (\Exception $ex) {
$this->getCache()->remove($path);
$this->logger->logException($ex, [
@ -392,7 +392,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$stat['storage_mtime'] = $mTime;
// run path based detection first, to use file extension because $tmpFile is only a random string
$mimetypeDetector = \OC::$server->getMimeTypeDetector();
$mimetypeDetector = \OC::$server->getMimeTypeDetector();
$mimetype = $mimetypeDetector->detectPath($path);
if ($mimetype === 'application/octet-stream') {
$mimetype = $mimetypeDetector->detect($tmpFile);

View File

@ -50,9 +50,15 @@ trait S3ObjectTrait {
'Key' => $urn
]);
$request = \Aws\serialize($command);
$headers = [];
foreach ($request->getHeaders() as $key => $values) {
foreach ($values as $value) {
$headers[] = "$key: $value";
}
}
$opts = [
'http' => [
'header' => $request->getHeaders()
'header' => $headers
]
];