Use credentials array only if values passed via conf.php
This commit is contained in:
parent
643832b2b8
commit
e3abc042a8
@ -82,31 +82,32 @@ class S3Storage extends AbstractData
|
|||||||
*/
|
*/
|
||||||
public function __construct(array $options)
|
public function __construct(array $options)
|
||||||
{
|
{
|
||||||
$this->_options['credentials'] = array();
|
if (is_array($options)) {
|
||||||
|
// AWS SDK will try to load credentials from environment if credentials are not passed via configuration
|
||||||
if (is_array($options) && array_key_exists('region', $options)) {
|
// ref: https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html#default-credential-chain
|
||||||
$this->_options['region'] = $options['region'];
|
if (isset($options['accesskey']) && isset($options['secretkey'])) {
|
||||||
}
|
$this->_options['credentials'] = array();
|
||||||
if (is_array($options) && array_key_exists('version', $options)) {
|
$this->_options['credentials']['key'] = $options['accesskey'];
|
||||||
$this->_options['version'] = $options['version'];
|
$this->_options['credentials']['secret'] = $options['secretkey'];
|
||||||
}
|
}
|
||||||
if (is_array($options) && array_key_exists('endpoint', $options)) {
|
if (array_key_exists('region', $options)) {
|
||||||
$this->_options['endpoint'] = $options['endpoint'];
|
$this->_options['region'] = $options['region'];
|
||||||
}
|
}
|
||||||
if (is_array($options) && array_key_exists('accesskey', $options)) {
|
if (array_key_exists('version', $options)) {
|
||||||
$this->_options['credentials']['key'] = $options['accesskey'];
|
$this->_options['version'] = $options['version'];
|
||||||
}
|
}
|
||||||
if (is_array($options) && array_key_exists('secretkey', $options)) {
|
if (array_key_exists('endpoint', $options)) {
|
||||||
$this->_options['credentials']['secret'] = $options['secretkey'];
|
$this->_options['endpoint'] = $options['endpoint'];
|
||||||
}
|
}
|
||||||
if (is_array($options) && array_key_exists('use_path_style_endpoint', $options)) {
|
if (array_key_exists('use_path_style_endpoint', $options)) {
|
||||||
$this->_options['use_path_style_endpoint'] = filter_var($options['use_path_style_endpoint'], FILTER_VALIDATE_BOOLEAN);
|
$this->_options['use_path_style_endpoint'] = filter_var($options['use_path_style_endpoint'], FILTER_VALIDATE_BOOLEAN);
|
||||||
}
|
}
|
||||||
if (is_array($options) && array_key_exists('bucket', $options)) {
|
if (array_key_exists('bucket', $options)) {
|
||||||
$this->_bucket = $options['bucket'];
|
$this->_bucket = $options['bucket'];
|
||||||
}
|
}
|
||||||
if (is_array($options) && array_key_exists('prefix', $options)) {
|
if (array_key_exists('prefix', $options)) {
|
||||||
$this->_prefix = $options['prefix'];
|
$this->_prefix = $options['prefix'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_client = new S3Client($this->_options);
|
$this->_client = new S3Client($this->_options);
|
||||||
|
Loading…
Reference in New Issue
Block a user