How to save image in S3 using pre-signed url and getting back the saved image url to save in Database

Viewed 979

I am using node as backend and I was able to save image in s3 but when i use getObject presigned url i get back url which download file but file is not an image it has local file location

1 Answers

As I understand you are facing two problems: 1. you want to get a download URL link of the file you just uploaded. 2. the file type that you download doesn't match its actual type. Let's answer one at the time. 1. pre-signed URLs are temporary (time manners) URLs with restricted access, therefore you can't get a permanent download URL link after you upload your object, what you can do is to generate a pre-signed URL every time you want to access it. If the object ACL is public you can access it using this template https://bucket-name.s3.Region.amazonaws.com/key name. 2. If you upload an object with a specified content-type it will be downloaded with the same content-type, so as I see it, by adding Content-Type header to your pre-signed URL creation & upload request, your problem will be solved.

Related