时间:2021-07-01 10:21:17 帮助过:15人阅读
define('AWS_KEY', '账号');
define('AWS_SECRET_KEY', '密码');
//define('AWS_CANONICAL_ID', 'your DHO Username');
//define('AWS_CANONICAL_NAME', 'Also your DHO Username!');
$HOST = 'IP';
// require the amazon sdk for php library
require_once 'sdk-1.6.2/sdk.class.php';
// Instantiate the S3 class and point it at the desired host
$Connection = new AmazonS3(array(
'key' => AWS_KEY,
'secret' => AWS_SECRET_KEY,
//'canonical_id' => AWS_CANONICAL_ID,
//'canonical_name' => AWS_CANONICAL_NAME,
));
$Connection->set_hostname($HOST);
$Connection->allow_hostname_override(false);
// Set the S3 class to use objects.dreamhost.com/bucket
// instead of bucket.objects.dreamhost.com
$Connection->enable_path_style();
echo "测试1";
$ListResponse = $Connection->list_buckets();
echo "测试2";
$Buckets = $ListResponse->body->Buckets->Bucket;
foreach ($Buckets as $Bucket) {
echo $Bucket->Name . "\t" . $Bucket->CreationDate . "
";
}