因此,我正在努力从s3存储桶中获取图像以在流星应用程序中显示客户端。我正在使用aws-sdk节点包。我正在服务器端的控制台中获取对象,如果将存储桶策略更改为public,它也可以正常工作。对象在启动时显示在控制台中但未在客户端显示,这一事实使我认为这是一个流星问题,我只是在查找有关此主题的文档方面遇到困难。
server.js
Meteor.startup(() => {
AWS.config.update({
accessKeyId: Meteor.settings.AWS.S3.accessId,
secretAccessKey: Meteor.settings.AWS.S3.secret
});
s3 = new AWS.S3({
region: "<my-region>"
});
var params = {
Bucket: "<my-bucket-name>"
};
s3.listObjects(
params,
Meteor.bindEnvironment(function(err, data) {
if (err) throw err;
console.log(data);
})
);
})
这是我的存储桶策略(当我将资源设置为*时可以,但是我希望将资源设置为特定的IAM帐户):
{
"Version": "2008-10-17",
"Id": "Policy-some-number",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<current-iam-account-in>"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<bucket-name>/*"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<current-iam-account-in>"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::<bucket-name>/*"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<current-iam-account-in>"
},
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::<bucket-name>"
}
]
}