Skip to content

Commit

Permalink
Implement generation of pre-signed object URLs using the expiration s…
Browse files Browse the repository at this point in the history
…etting.

Fixes #1.
  • Loading branch information
mikesname committed Nov 10, 2016
1 parent 386d610 commit c4db4b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion libraries/Omeka/Storage/Adapter/AmazonS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public function store($source, $dest)
$result = $this->_s3->putObject([
'ACL' => $this->_getAcl(),
'Bucket' => $this->_getBucket(),
'Expiration' => $this->_getExpiration(),
'SourceFile' => $source,
'Key' => $dest
]);
Expand Down Expand Up @@ -127,6 +126,17 @@ public function delete($path)
*/
public function getUri($path)
{
if ($expiration = $this->_getExpiration()) {
$cmd = $this->_s3->getCommand('GetObject', [
'Bucket' => $this->_getBucket(),
'Key' => $path
]);
$request = $this->_s3->createPresignedRequest($cmd, "+$expiration minutes");
$uri = (string)$request->getUri();
debug("Omeka_Storage_Adapter_AmazonS3: generating URI to expire in $expiration minutes: $uri");
return $uri;
}

return $this->_s3->getObjectUrl($this->_getBucket(), $path);
}

Expand Down
6 changes: 3 additions & 3 deletions plugin.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[info]
name="AmazonS3StorageAdapter"
name="Amazon S3 Storage Adapter"
author="EHRI"
description="Storage adapter for Amazon S3 based on the official AWS SDK."
link="https://github.com/EHRI/omeka-storage-adapter-amazon-s3"
link="https://github.com/EHRI/omeka-amazon-s3-storage-adapter"
license="European Union Public Licence (EUPL) v1.1"
omeka_minimum_version="2.0"
omeka_target_version="2.4"
version="0.1"
version="0.2"

0 comments on commit c4db4b2

Please sign in to comment.