angular - aws-amplify S3 存储上传文件,但将它们设置为“私有”,尽管有明确的公共访问配置
问题描述
我正在尝试将文件上传到具有公共访问权限的 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/
推荐阅读
- c# - 由于可空类型更改为枚举,迁移后 EF 核心更新失败
- dependencies - sr-feuser-register 有或没有弃用 rsaauth
- c# - 行为异步等待控制台应用程序与 WPF
- java - 针对 json 模式的 Json 验证失败
- javascript - 在我发送回调函数上的数据之前,我如何才能等到整个批次的请求都被提出并解决了承诺?
- excel - 根据星期几自动运行宏
- r - 在 RStudio 中使用 bookdown::publish_book() 配置 bookdown.org 帐户时出错
- core-data - 如何在目标c中添加coreData关系
- html - 如何限制 Ionic 中时间选择器的范围?
- wordpress - ACF。如何使用文件更新转发器字段?