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'])) {
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
try {
$result = $this->connection->doesObjectExist(
$this->bucket,
- $path
+ $this->cleanKey($path)
);
} catch (S3Exception $e) {
\OCP\Util::writeLog('files_external', $e->getMessage(), \OCP\Util::ERROR);
$result = $this->connection->headObject(array(
'Bucket' => $this->bucket,
- 'Key' => $path
+ 'Key' => $this->cleanKey($path)
));
$stat = array();
if ($path != '.') {
$path .= '/';
}
-
- if ($this->connection->doesObjectExist($this->bucket, $path)) {
+ if ($this->connection->doesObjectExist($this->bucket, $this->cleanKey($path))) {
return 'dir';
}
} catch (S3Exception $e) {
try {
$result = $this->connection->deleteObject(array(
'Bucket' => $this->bucket,
- 'Key' => $path
+ 'Key' => $this->cleanKey($path)
));
$this->testTimeout();
} catch (S3Exception $e) {
try {
$result = $this->connection->getObject(array(
'Bucket' => $this->bucket,
- 'Key' => $path,
+ 'Key' => $this->cleanKey($path),
'SaveAs' => $tmpFile
));
} catch (S3Exception $e) {
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);
}
$result = $this->connection->copyObject(array(
'Bucket' => $this->bucket,
- 'Key' => $path,
+ 'Key' => $this->cleanKey($path),
'Metadata' => $metadata,
'CopySource' => $this->bucket . '/' . $path
));
} else {
$result = $this->connection->putObject(array(
'Bucket' => $this->bucket,
- 'Key' => $path,
+ 'Key' => $this->cleanKey($path),
'Metadata' => $metadata
));
$this->testTimeout();
try {
$result = $this->connection->copyObject(array(
'Bucket' => $this->bucket,
- 'Key' => $path2,
+ 'Key' => $this->cleanKey($path2),
'CopySource' => $this->bucket . '/' . $path1
));
$this->testTimeout();
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)