Incorrect content-type in object system defined metadata when uploading image to AWS S3
Closed this issue · 0 comments
Problem:
When I tried to upload an image to my bucket in AWS S3, the metadata of the uploaded object showing application/octet-stream
as Content-Type
value. So, if I open that image using the public/object URL, it will force me to download the image instead of preview the image in the browser.
Expected Behavior:
Content-Type
is showing value based on mime-type of uploaded file (for example: image/png for .png file). As a result, when I upload an image and open the public URL from req.body.file
, the browser can preview the image. This behavior is mandatory for libraries like tensorflow.js, etc.
Suggestion:
According to this comment:
it will add application/octet-stream if ContentType is not passed in the original request.
I think inserting ContentType: file.mimetype
to s3.js as params if the mime-type is not invalid will solve this issue.
Thank you 👍