I'm trying to upload files to AWS S3 Storage with public access but despite of explicitly configure the public access on the code the files are uploaded as private instead. I'm using the aws-amplify package on an Angular app.
This is the code I'm using:
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);
});
}
Any idea of why S3 is ignoring the public access I'm indicating and putting the files as private? Thanks in advance!
Check your bucket property setup; maybe it is configured to block public access no matter what’s your permission. Also, check your account setting that doesn’t block public access to S3 https://aws.amazon.com/s3/features/block-public-access/