![](/img/trans.png)
[英]Why can't I access my s3 private objects using AWS Amplify storage.get with Admin access and proper policy set. Getting 403 error
[英]aws-amplify S3 Storage uploads files but put them as "private" despite of explicit public access configuration
我正在尝试使用公共访问将文件上传到 AWS S3 存储,但尽管在代码上明确配置了公共访问,但文件还是被上传为私有文件。 我在 Angular 应用程序上使用aws-amplify包。
这是我正在使用的代码:
public onSubmit() {
this.form.disable();
const contentType: string = this.imgFile.extension === 'png' ? 'image/png' : 'image/jpeg';
// Image upload to AWS S3 storage.
Storage.put(this.imgFile.name, this.imgFile.content, {
progressCallback: (progress: any) => {
console.log(`Uploaded: ${progress.loaded}/${progress.total}`);
},
contentType: contentType,
ACL: 'public-read',
visibility: 'public',
level: 'public',
}).then((result: any) => {
this.img = S3_URL + replaceAll(result.key, ' ', '+');
// GraphQL API mutation service.
this.bannerService.createBanner(
this.img,
this.form.value.channel,
this.form.value.trailer,
this.backgroundColor,
this.buttonColor,
this.textColor,
);
// Re-enable the form.
this.form.enable({
onlySelf: true,
emitEvent: true,
});
// Clean all form fields.
this.formElement.nativeElement.reset();
}).catch((err) => {
console.log('error =>', err);
});
}
知道为什么 S3 忽略我指示的公共访问并将文件设为私有吗? 提前致谢!
检查您的存储桶属性设置; 也许它被配置为无论您的许可如何,都可以阻止公共访问。 此外,请检查您的帐户设置,该设置不会阻止对 S3 的公共访问https://aws.amazon.com/s3/features/block-public-access/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.