1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32:39 +01:00

Add support for S3 endpoint regions.

Summary:
Allows to use file storage in different Amazon S3 regions as well as it
should support different file storage services with S3 compliant API
(eg.: Bashos' Riak CS).

Test Plan:
1. Create S3 bucket in non-default AWS Region (e.g. EU/Ireland).
2. Set appropriate bucket policy to allow upload & download objects for the specified access credentials.
3. Set `amazon-s3.endpoint` in your configuration file to an appropriate value (e.g. `s3-eu-west-1.amazonaws.com` for EU region).

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3965
This commit is contained in:
Julius Seporaitis 2012-11-16 04:07:57 -08:00 committed by epriestley
parent bf4f74dbb3
commit 2b00f5e8b6
2 changed files with 10 additions and 1 deletions

View file

@ -883,6 +883,10 @@ return array(
'amazon-s3.access-key' => null,
'amazon-s3.secret-key' => null,
// To use a custom endpoint, specify it here. Normally, you do not need to
// configure this.
'amazon-s3.endpoint' => null,
// Set this to a valid Amazon S3 bucket to store files there. You must also
// configure S3 access keys above.
'storage.s3.bucket' => null,

View file

@ -98,13 +98,18 @@ final class PhabricatorS3FileStorageEngine
$access_key = PhabricatorEnv::getEnvConfig('amazon-s3.access-key');
$secret_key = PhabricatorEnv::getEnvConfig('amazon-s3.secret-key');
$endpoint = PhabricatorEnv::getEnvConfig('amazon-s3.endpoint');
if (!$access_key || !$secret_key) {
throw new PhabricatorFileStorageConfigurationException(
"Specify 'amazon-s3.access-key' and 'amazon-s3.secret-key'!");
}
$s3 = new S3($access_key, $secret_key, $use_ssl = true);
if ($endpoint !== null) {
$s3 = new S3($access_key, $secret_key, $use_ssl = true, $endpoint);
} else {
$s3 = new S3($access_key, $secret_key, $use_ssl = true);
}
$s3->setExceptions(true);