Reputation: 439
Hi I'm generating the s3 presigned "GET" urls to display images using code modified from https://gist.github.com/kelvinmo/d78be66c4f36415a6b80
Ideally I should also be able to generate a presigned delete URL, put it in the browser and the image would get deleted.
I would like to modify this for the delete operation, there seems to be no info online on how to do this with a presigned url aside from the aws docs which are vague but say it's possible. I haven't managed to find any online tutorials using presigned urls for delete.
https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
I tried just changing the Get to Delete in the request as many docs say but this creates an incorrect signature:
SignatureDoesNotMatchThe request signature we calculated does not match the signature you provided. Check your key and signing method
It looks like the s3 is matching the DELETE signature with PUT signature and saying it doesn't match, so how to do a delete?!
Any clues or links would be helpful. I'm assuming the current GET script is sending the wrong parameters or something.
Upvotes: 3
Views: 9663
Reputation: 77024
This wouldn't be a URL that you can share, but it would probably accomplish your intent of being able to perform an operation via simple tools.
According to the AWS docs, you can do this with the correct authorization header:
DELETE /my-second-image.jpg HTTP/1.1
Host: bucket.s3.amazonaws.com
Date: Wed, 12 Oct 2009 17:50:00 GMT
Authorization: authorization string
Content-Type: text/plain
In this case, the header you need to set is, more or less, the pre-signed URL:
TODO: I'll be back with more info when I figure it out...
Upvotes: 0
Reputation: 52393
Pre-signed URL is supported for:
It is not supported for:
The reason you are getting SignatureDoesNotMatch
is the operation is part of the signature. You cannot change the operation from GET to DELETE and expect the signature to match.
Upvotes: 9