Skip to content

Commit

Permalink
Merge pull request #7186 from nextcloud/s3-download-stream-fix-12
Browse files Browse the repository at this point in the history
[12] Fix s3 download and touch
  • Loading branch information
schiessle committed Nov 17, 2017
2 parents 9942c39 + e041c7a commit 031bde5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/private/Files/ObjectStore/ObjectStoreStorage.php
Expand Up @@ -364,7 +364,7 @@ public function touch($path, $mtime = null) {
$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, [
Expand Down Expand Up @@ -392,7 +392,7 @@ public function writeBack($tmpFile, $path) {
$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);
Expand Down
8 changes: 7 additions & 1 deletion lib/private/Files/ObjectStore/S3ObjectTrait.php
Expand Up @@ -50,9 +50,15 @@ function readObject($urn) {
'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
]
];

Expand Down

0 comments on commit 031bde5

Please sign in to comment.