mirror of
https://github.com/SociallyDev/Spaces-API.git
synced 2025-07-16 10:03:01 -07:00
Added support for different AWS SDK loading methods
This commit is contained in:
parent
1d5b8b9dc8
commit
bc8593a9e9
1 changed files with 12 additions and 1 deletions
13
spaces.php
13
spaces.php
|
@ -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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue