弹弓无法上传到 S3



Slingshot 包与 Meteor 一起使用,直接从客户端将图像上传到 S3。我在批准工作的其他项目中使用的相同代码。即使是我的本地设置,我也可以将图像上传到云,但不能使用其部署的版本,这是相同的。错误如下:

Failed to upload file to cloud storage [Bad Request - 400]

the region 'us-east-1' is wrong; expecting 'eu-central-1'(但它没有告诉在哪里...

有什么想法吗?

这是流星弹弓指令的初始化:

const s3Settings = Meteor.settings.private.S3settings;
Slingshot.createDirective("userProfileImages", Slingshot.S3Storage, {
AWSAccessKeyId: s3Settings.AWSAccessKeyId,
AWSSecretAccessKey: s3Settings.AWSSecretAccessKey,
bucket: s3Settings.AWSBucket,
region: s3Settings.AWSRegion,
acl: "public-read",
authorize: function () {
if (!this.userId) {
const message = "Please login before posting images";
throw new Meteor.Error("Login Required", message);
}
return true;
},
key: function (file) {
const user = Meteor.users.findOne(this.userId);
return user.username + "/" + file.name;
}
});

这是我的 Amazon S3 CORS 配置:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>10000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

我没有存储桶策略。 访问控制都是公共的。

感谢帮助。

问题是我。我在设置中将区域定义为AWSregion(r(,而我在要设置的代码中将其称为AWSRegion(R(。所以它是未定义的,不起作用。

解决方案是确保正确键入案例。

相关内容

  • 没有找到相关文章

最新更新