aws.s3 R Package - put() image for browser display

Viewed 106

I'm trying to put an image in a s3 bucket (using the aws.s3 R Package) and then see it in browser (not prompt a download of the image when visiting the url). When I write it, it's getting the content type of a binary/octet-stream. Even when I manually change the content type to "image/jpeg" it forces the download prompt when i put the image s3 path into a browser (from what I've found online changing to type image/jpeg is supposed to be the key to have it display in browser vs prompt download).

What should the aws.s3::put_object() look like to display the image in the browser automatically?

Thanks!

aws.s3::put_object(file = [file path to jpeg], 
                   object = [object name], bucket = [bucket name], 
                   show_progress = T, 
                   opts = list("acl"="public-read","content-type"="image/jpeg"))
1 Answers

You are right. Only required thing is content-type to be impage/jpeg. Just make sure that in browser when u downloading this is the content-type it shows. It depends on your browser if browser supports that content-type it shows in browser; if not then it downloads it.

Try opening your URL in other browser. OR try opening some other image URL (for ex. https://bsmedia.business-standard.com/_media/bs/img/article/2020-06/24/full/1593016904-6365.jpg ) in your same browser.

Can you send me the URL of your image ?

Related