Comments for Delete a Note


From @jayair on Fri Apr 20 2018 17:30:31 GMT+0000 (UTC)

@alex-romanov A couple of things to check. Check the CORS config we set in this chapter - And make sure the IAM policy in the chapter is set properly - There are also some tips on debugging the IAM policy here -


Added a delete function to aws-libs. It works but how can I get information out of the promise I get from delete a file? I want to know if the delete was succesfull e.g. if the file existed. The docs says: * Promise resolves upon successful removal of the object but I don’t know what that means.

 export async function s3Delete(filename) {
     const promise = await Storage.vault.remove(filename);
     //how do I check if object was successfully removed?
     return true;

I’m not entirely sure for this case but for promises with async/await you want to use the try/catch pattern. So wrap it in a try/catch and it should throw an error if it failed to remove it.

1 Like

Hey @namelesswc can you help me? I think Storage.remove() needs the key of the file right? How did you get it? I can only get the URL

EDIT: the request doesn’t throw an error, I tried to construct the key myself, it worked, but S3 responds with a 204 and doesn’t delete the file!


I think you just need the key of the file. This is the same as the one we used while uploading the file. If you have the URL strip the rest of the URL info to just get the filename.


@jayair Yeah got it just now reading again! Since the key on the AWS console includes stuff like “private/…” I thought we needed that here as well. Thanks

1 Like