AWS S3文件上传导致“ 403禁止”响应:AccessDenied

时间:2019-01-03 11:29:06

标签: amazon-web-services amazon-s3

这是我的代码

<?php
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;

error_reporting(0);

function pre($arr){
    echo '<pre>';print_r($arr);echo '</pre>';
}

if($_FILES['image']['name'] != ''){

require 'aws/aws-autoloader.php';

$client = S3Client::factory([
    'version' => 'latest',
    'region'  => 'eu-west-2',
    'credentials' => [
        'key'    => "XXXXXXX",
        'secret' => "XXXXXXX"
    ],
    'scheme' => 'http'
 ]);
try {
    $insert = $client->putObject([
        'Bucket'     =>'xxx',
        'Key'        => $_FILES["image"]["name"],
        'SourceFile' => $_FILES["image"]["tmp_name"],
        'ACL'        => 'public-read'
    ]);
} catch (S3Exception $e) {
    // Catch an S3 specific exception.
    echo $e->getMessage();
}
die;
}
?>

<!DOCTYPE html>
<html>
<body>

<form action="aws.php" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="image" id="image">
    <input type="submit" value="Upload Image" name="submit">
</form>

</body>
</html>

当我尝试上传图片时,出现此错误

  

在“ http://xxx.s3.eu-west-2.amazonaws.com/b_browse.png”上执行“ PutObject”时出错; AWS HTTP错误:客户端错误:PUT http://xxx.s3.eu-west-2.amazonaws.com/b_browse.png导致了403 Forbidden响应:AccessDeniedAccess Denied07E90B(被截断了...)AccessDenied(客户端):Access Denied-AccessDeniedAccess Denied07E90B12D3A0DBA15kSo11cfv57kBQ3sBo9dHHtZb4XtCy3B

关于什么可能是问题的任何想法?我也已向用户授予FullS3Permission。

0 个答案:

没有答案