Skip to content

Commit

Permalink
Addition of endpoint option
Browse files Browse the repository at this point in the history
  • Loading branch information
timmmmyboy committed Jun 3, 2020
1 parent c4db4b2 commit 3bd6013
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Omeka Amazon S3 Storage Adapter
Omeka Amazon S3 Compatible Storage Adapter
===============================

This is an S3 storage adapter for Omeka that provides an _alternative_ to
This is an S3 compatible storage adapter for Omeka that provides an _alternative_ to
the `Omeka_Storage_Adapter_ZendS3` which ships with the application.

The main differences are:

- this adapter uses the official AWS S3 SDK library
- it requires PHP 5.5 or above
- requires you supply the AWS region in the configuration
- requires you supply the custom endpoint in the configuration
- it supports the V4 authorization mechanism that is required on AWS
regions created after July 2014

Expand All @@ -23,7 +23,7 @@ storage.adapter = Omeka_Storage_Adapter_AmazonS3
storage.adapterOptions.accessKeyId = MY-ACCESS-KEY-ID
storage.adapterOptions.secretAccessKey = MY-SECRET-KEY
storage.adapterOptions.bucket = my-bucket-name
storage.adapterOptions.region = eu-central-1
storage.adapterOptions.endpoint = https://yourcustomendpoint
```

**Note**: This plugin has not yet been tested much so use at your own risk!
6 changes: 6 additions & 0 deletions libraries/Omeka/Storage/Adapter/AmazonS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Omeka_Storage_Adapter_AmazonS3 implements Omeka_Storage_Adapter_AdapterInt
const AWS_KEY_OPTION = 'accessKeyId';
const AWS_SECRET_KEY_OPTION = 'secretAccessKey';
const REGION_OPTION = 'region';
const ENDPOINT_OPTION = 'endpoint';
const BUCKET_OPTION = 'bucket';
const EXPIRATION_OPTION = 'expiration';

Expand Down Expand Up @@ -40,6 +41,10 @@ public function __construct(array $options = array())
throw new Omeka_Storage_Exception('You must specify your AWS access key and secret key to use the AmazonS3 storage adapter.');
}

if (!array_key_exists(self::ENDPOINT_OPTION, $options)) {
throw new Omeka_Storage_Exception('You must specify an S3-compatible endpoint to use the AmazonS3 storage adapter.');
}

if (!array_key_exists(self::REGION_OPTION, $options)) {
throw new Omeka_Storage_Exception('You must specify an S3 region name to use the AmazonS3 storage adapter.');
}
Expand All @@ -50,6 +55,7 @@ public function __construct(array $options = array())

$this->_s3 = new Aws\S3\S3Client([
'version' => 'latest',
'endpoint' => $options[self::ENDPOINT_OPTION],
'region' => $options[self::REGION_OPTION]
]);
}
Expand Down
8 changes: 4 additions & 4 deletions plugin.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[info]
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-amazon-s3-storage-adapter"
name="S3 Compatible Storage Adapter"
author="Tim Owens"
description="Storage adapter for Amazon S3-compatible storage on the official AWS SDK. Fork of https://github.com/EHRI/omeka-amazon-s3-storage-adapter"
link="https://github.com/timmmmyboy/omeka-amazon-s3-storage-adapter"
license="European Union Public Licence (EUPL) v1.1"
omeka_minimum_version="2.0"
omeka_target_version="2.4"
Expand Down

0 comments on commit 3bd6013

Please sign in to comment.