I’m using Amplify gen 2 following the docs here:
https://docs.amplify.aws/angular/build-a-backend/storage/set-up-storage/
My storage definition:
export const storage = defineStorage({
name: 'assets',
access: (allow) => ({
'images/*': [
allow.guest.to(['read']),
allow.authenticated.to(['write', 'read']),
allow.groups(['Admin']).to(['write', 'read', 'delete'])
]
})
});
Backend:
const backend = defineBackend({
auth,
data,
storage
});
Upload code:
const result = await uploadData({
path: `images/test.jpg`, // temp hardcode name just for testing
data: this.imageSrc,
options: {
onProgress: ({ transferredBytes, totalBytes }) => {
if (totalBytes) {
console.log(`Upload progress ${Math.round((transferredBytes / totalBytes) * 100)} %`);
}
},
},
}).result;
The bucket is created as part of my sandbox with the defined permissions. However, when I try to upload, I get:
- Response: 403 Forbidden
- Error : AccessDenied
Note that I can get images using code such as:
const pic = await getUrl({
path: "images/pic.jpg"
});
It’s only uploading that I’m having issues. I tried manually editing the bucket permissions but this has had no impact.
During upload, the console.log line is hit multiple times, at 100% is when the “Access Denied” error occurs