/** * Get bucket list for credential * @param $key_id * @param $secret_key * @return array * @throws Exception */ public static function get_bucket_list($key_id, $secret_key) { require_once PATH_THIRD . 'assets/sources/s3/lib/Assets_S3.php'; $s3 = new Assets_S3($key_id, $secret_key); $buckets = @$s3->listBuckets(); if (empty($buckets)) { throw new Exception(lang('wrong_credentials')); } $bucket_list = array(); foreach ($buckets as $bucket) { $location = $s3->getBucketLocation($bucket); $bucket_item = array('bucket' => $bucket, 'location' => $location, 'url_prefix' => 'http://' . self::get_endpoint_by_location($location) . '/' . $bucket . '/'); $bucket_list[$bucket] = (object) $bucket_item; } return $bucket_list; }