0
从昨天开始,当我试图将文件上传到我的S3存储桶之一时,我得到了一个Access Denied错误。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"
}
我在这个一直盯着在过去的几个小时,但我实在看不出有什么问题。根据this链接,它应该是配置策略的正确方法。而且昨天这工作得很好。
编辑> 我刚刚尝试过“行动”:“*”,我得到了同样的结果。
显然这是罪魁祸首:ACL:'公众阅读'。不知道为什么,因为我授予s3:PutObjectACL。据我所知,这应该允许你这样做。 – Bjorn121