我在某種程度上失去了這裏,我是aws新人,所以我已經在myproject中安裝了aws-sdk-php,並且我正在測試上傳;這裏是一塊腳本代碼:爲什麼使用aws-sdk-php上傳文件時拒絕Acces?
require '.vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
// Instantiate an S3 client
$s3 = S3Client::factory(array(
'credentials' => array(
'key' => 'key ... ',
'secret' => 'secret key ... ',
)
));
$file_name = $_FILES['file']['tmp_name'];
try {
$s3->putObject(array(
'Bucket' => 'bucket_name',
'Key' => $_FILES['file']['name'],
'Body' => fopen($file_name, 'r'),
'ACL' => 'public-read',
));
echo " upload succed !!";
} catch (S3Exception $e) {
echo "There was an error uploading the file.\n";
echo $e->getMessage() . "\n";
}
這個代碼是從本地測試工作正常,但試圖做在一個文件夾中的S3項目測試相同的腳本時;我得到這個錯誤:
There was an error uploading the file. Access Denied
任何想法PLZ? 謝謝。
你檢查了你的權限嗎? –
謝謝,我該如何檢查?因爲它不是誰控制訪問權限!我想了解從哪裏可以得到的錯誤.... – user3911183