dwyl / imgup

πŸŒ… Effortless image uploads to AWS S3 with automatic resizing including REST API.

Home Page:https://imgup.fly.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: Cannot include `S3` image in a `GitHub` issue comment

nelsonic opened this issue Β· comments

commented

We are able to upload images to S3 via REST API πŸŽ‰
URL: https://imgup.fly.dev/api/images
Docs: https://github.com/dwyl/imgup/blob/main/api.md#4-testing-the-api-from-hoppscotch

image
{
  "compressed_url": "https://s3.eu-west-3.amazonaws.com/imgup-compressed/zb2rhoFgi1PXSfoeFi9PGT3R33fpq4iAsQJRuU2Yoy7yMzhj3.jpg",
  "url": "https://s3.eu-west-3.amazonaws.com/imgup-original/zb2rhoFgi1PXSfoeFi9PGT3R33fpq4iAsQJRuU2Yoy7yMzhj3.jpg"
}

The problem is when we attempt to view one of these images directly in the browser e.g. by copy-pasting the URL into a new browser tab: https://s3.eu-west-3.amazonaws.com/imgup-original/zb2rhoFgi1PXSfoeFi9PGT3R33fpq4iAsQJRuU2Yoy7yMzhj3.jpg

It automatically downloads the file instead of displaying it in the browser.
I suspect this is because the MIME Type is not correctly set on S3 ...

This is why it does not display the image in a GitHub issue comment or .md file ...

![img](https://s3.eu-west-3.amazonaws.com/imgup-original/zb2rhoFgi1PXSfoeFi9PGT3R33fpq4iAsQJRuU2Yoy7yMzhj3.jpg)

img

... πŸ€·β€β™‚οΈ

@LuchoTurtle do you have time to investigate this?
I've tried reading the docs: https://hexdocs.pm/ex_aws_s3/ExAws.S3.html#t:initiate_multipart_upload_opt/0
but can't seem to find where to put the Content-Type for the uploaded file ... πŸ€·β€β™‚οΈ

I can look into this after I'm done with the Flutter task.

commented

Adding content_type to the S3.upload/4 function worked.

image image

Full size: https://s3.eu-west-3.amazonaws.com/imgup-original/zb2rhhAwsGcVnvNMgmKJjAyFLiFM5KohnPkiEnftvTXQKV9fE.jpg
full

Sadly the compressed image still does not have the correct metadata:

small

@LuchoTurtle Thanks for looking in to this. πŸ‘Œ

commented

Think it might be this line:

ContentType: "image",

Needs to read the ContentType of the original image and set it accordingly. πŸ’­

commented

@LuchoTurtle while you're editing index.js consider looking at #66 πŸ’­