我使用的是。在我的应用程序中,我接受表单中的密钥和秘密值,并传递到Aws。这是我的密码。
<?php
require 'aws-autoloader.php';
use Aws\S3\S3Client;
try {
$s3Client = S3Client::factory(array(
'key' => 'my key',
'secret' => 'my secret key'
));
}
catch(S3Exception $e) {
echo 'Msg' . $e->getMessage();
}
?>发布于 2015-03-31 11:42:07
正如Michael所指出的,您必须提出一个实际的请求来检查connection.AWS,这会阻止任何不必要的验证请求,因为这些验证请求会影响应用程序的性能和使用费用。
但是,如果需要验证,可以在桶上使用ListBucket或HEAD请求。
看看这个最好的实践article。
require 'vendor/autoload.php';
use Aws\S3\S3Client;
try {
// Instantiate the S3 client with your AWS credentials
$s3Client = S3Client::factory(array(
'credentials' => array(
'key' => 'YOUR_AWS_ACCESS_KEY_ID',
'secret' => 'YOUR_AWS_SECRET_ACCESS_KEY',
)
));
$buckets = $s3Client->listBuckets();
}
catch(Exception $e) {
exit($e->getMessage());
} 要回答第二个question.You,可以使用doesObjectExist函数,它返回一个布尔值。
https://stackoverflow.com/questions/29361638
复制相似问题