Added support for different AWS SDK loading methods

This commit is contained in:
Devang Srivastava 2018-02-03 23:06:03 +05:30 committed by GitHub
parent 1d5b8b9dc8
commit bc8593a9e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,4 @@
<?php <?php
require_once(dirname(__FILE__)."/aws/autoloader.php");
class SpacesConnect { class SpacesConnect {
/* /*
@ -9,12 +8,24 @@ class SpacesConnect {
*/ */
function __construct($access_key, $secret_key, $spaceName = "", $region = "nyc3", $host = "digitaloceanspaces.com") { function __construct($access_key, $secret_key, $spaceName = "", $region = "nyc3", $host = "digitaloceanspaces.com") {
//Only pulled if an AWS class doesn't already exist.
$non_composer_aws_lib = dirname(__FILE__)."/aws/autoloader.phpx";
if(!empty($spaceName)) { if(!empty($spaceName)) {
$endpoint = "https://".$spaceName.".".$region.".".$host; $endpoint = "https://".$spaceName.".".$region.".".$host;
} }
else { else {
$endpoint = "https://".$region.".".$host; $endpoint = "https://".$region.".".$host;
} }
if(!class_exists('Aws\S3\S3Client')) {
if(file_exists($non_composer_aws_lib)) {
require_once($non_composer_aws_lib);
}
else {
throw new SpacesAPIException(@json_encode(["error" => ["message" => "No AWS class loaded.", "code" => "no_aws_class", "type" => "init"]]));
}
}
try { try {
$this->client = Aws\S3\S3Client::factory(array( $this->client = Aws\S3\S3Client::factory(array(
'region' => $region, 'region' => $region,