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:
committed by
epriestley
parent
bf4f74dbb3
commit
2b00f5e8b6
@@ -883,6 +883,10 @@ return array(
|
|||||||
'amazon-s3.access-key' => null,
|
'amazon-s3.access-key' => null,
|
||||||
'amazon-s3.secret-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
|
// Set this to a valid Amazon S3 bucket to store files there. You must also
|
||||||
// configure S3 access keys above.
|
// configure S3 access keys above.
|
||||||
'storage.s3.bucket' => null,
|
'storage.s3.bucket' => null,
|
||||||
|
|||||||
@@ -98,13 +98,18 @@ final class PhabricatorS3FileStorageEngine
|
|||||||
|
|
||||||
$access_key = PhabricatorEnv::getEnvConfig('amazon-s3.access-key');
|
$access_key = PhabricatorEnv::getEnvConfig('amazon-s3.access-key');
|
||||||
$secret_key = PhabricatorEnv::getEnvConfig('amazon-s3.secret-key');
|
$secret_key = PhabricatorEnv::getEnvConfig('amazon-s3.secret-key');
|
||||||
|
$endpoint = PhabricatorEnv::getEnvConfig('amazon-s3.endpoint');
|
||||||
|
|
||||||
if (!$access_key || !$secret_key) {
|
if (!$access_key || !$secret_key) {
|
||||||
throw new PhabricatorFileStorageConfigurationException(
|
throw new PhabricatorFileStorageConfigurationException(
|
||||||
"Specify 'amazon-s3.access-key' and 'amazon-s3.secret-key'!");
|
"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);
|
$s3->setExceptions(true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user