从昨天开始,当我尝试将文件上传到我的一个 S3 存储桶时,我收到了拒绝访问错误。
Javascript代码:
var pass = new stream.PassThrough();
var contentType = (input.fileName.endsWith('.html') ? 'text/html' : 'text/javascript');
var params = {
Bucket: 'BUCKET_NAME',
Key: input.fileName,
Body: pass,
ACL: 'public-read',
ContentType: contentType
};
S3.upload(params, function(err, data) {
if (err) {
console.error('Error while uploading file: ' + err + '. Uploading file ' + params.Key + ' to Bucket ' + params.Bucket + '.');
throw err
}
});
return pass;
我最初的想法是,这是因为 IAM 政策,虽然我没有改变任何东西,它以前工作。
IAM 政策:
{
"Action": [
"s3:PutObject",
"s3:PubObjectACL"
],
"Resource": [
"arn:aws:s3:::BUCKET_NAME/*"
],
"Effect": "Allow"
}
过去几个小时我一直在盯着这个,但我真的看不出问题出在哪里。根据此链接,它应该是配置策略的正确方法。昨天这工作正常。
编辑>我刚刚尝试使用“Action”:“*”,我得到了相同的结果。