diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-07-08 14:25:47 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-07-08 14:25:47 +0200 |
commit | 46ba08a0b0329615708ca05f058f7127b6de103c (patch) | |
tree | 23d99a9cafd12a7cfdf6779e2fcc59d00966a8bc | |
parent | 687cd7fe83fc40d7bc7d2ba7df5b495bf7bebdca (diff) | |
parent | 599ab7a80224ad667aaaa1ca7e23f1386d196305 (diff) | |
download | nextcloud-server-46ba08a0b0329615708ca05f058f7127b6de103c.tar.gz nextcloud-server-46ba08a0b0329615708ca05f058f7127b6de103c.zip |
Merge pull request #9509 from owncloud/ctjctj-fix_amazons3
Fix Signiture Does Not Match when mounting Amazon S3 external storage
-rw-r--r-- | apps/files_external/lib/amazons3.php | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index 7ff17f0e98a..10fc626c5da 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -72,6 +72,12 @@ class AmazonS3 extends \OC\Files\Storage\Common { sleep($this->timeout); } } + private function cleanKey($path) { + if ($path === '.') { + return '/'; + } + return $path; + } public function __construct($params) { if (!isset($params['key']) || !isset($params['secret']) || !isset($params['bucket'])) { @@ -118,11 +124,10 @@ class AmazonS3 extends \OC\Files\Storage\Common { throw new \Exception("Creation of bucket failed."); } } - if (!$this->file_exists('.')) { $result = $this->connection->putObject(array( 'Bucket' => $this->bucket, - 'Key' => '.', + 'Key' => $this->cleanKey('.'), 'Body' => '', 'ContentType' => 'httpd/unix-directory', 'ContentLength' => 0 @@ -167,7 +172,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { try { $result = $this->connection->doesObjectExist( $this->bucket, - $path + $this->cleanKey($path) ); } catch (S3Exception $e) { \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); @@ -261,7 +266,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { $result = $this->connection->headObject(array( 'Bucket' => $this->bucket, - 'Key' => $path + 'Key' => $this->cleanKey($path) )); $stat = array(); @@ -291,8 +296,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { if ($path != '.') { $path .= '/'; } - - if ($this->connection->doesObjectExist($this->bucket, $path)) { + if ($this->connection->doesObjectExist($this->bucket, $this->cleanKey($path))) { return 'dir'; } } catch (S3Exception $e) { @@ -309,7 +313,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { try { $result = $this->connection->deleteObject(array( 'Bucket' => $this->bucket, - 'Key' => $path + 'Key' => $this->cleanKey($path) )); $this->testTimeout(); } catch (S3Exception $e) { @@ -332,7 +336,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { try { $result = $this->connection->getObject(array( 'Bucket' => $this->bucket, - 'Key' => $path, + 'Key' => $this->cleanKey($path), 'SaveAs' => $tmpFile )); } catch (S3Exception $e) { @@ -380,7 +384,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { try { $result = $this->connection->headObject(array( 'Bucket' => $this->bucket, - 'Key' => $path + 'Key' => $this->cleanKey($path) )); } catch (S3Exception $e) { \OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR); @@ -407,7 +411,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { } $result = $this->connection->copyObject(array( 'Bucket' => $this->bucket, - 'Key' => $path, + 'Key' => $this->cleanKey($path), 'Metadata' => $metadata, 'CopySource' => $this->bucket . '/' . $path )); @@ -415,7 +419,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { } else { $result = $this->connection->putObject(array( 'Bucket' => $this->bucket, - 'Key' => $path, + 'Key' => $this->cleanKey($path), 'Metadata' => $metadata )); $this->testTimeout(); @@ -436,7 +440,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { try { $result = $this->connection->copyObject(array( 'Bucket' => $this->bucket, - 'Key' => $path2, + 'Key' => $this->cleanKey($path2), 'CopySource' => $this->bucket . '/' . $path1 )); $this->testTimeout(); @@ -535,7 +539,7 @@ class AmazonS3 extends \OC\Files\Storage\Common { try { $result= $this->connection->putObject(array( 'Bucket' => $this->bucket, - 'Key' => self::$tmpFiles[$tmpFile], + 'Key' => $this->cleanKey(self::$tmpFiles[$tmpFile]), 'SourceFile' => $tmpFile, 'ContentType' => \OC_Helper::getMimeType($tmpFile), 'ContentLength' => filesize($tmpFile) |