Wrong mimetype when sending image to S3 with Laravel

Asked

Viewed 67 times

1

I’m using Laravel 5.3 and sending images to Amazon S3.

I have already put the rules in Bucket so that it is public and I am sending the image as follows:

request()->file('avatar')->storeAs('uploads/143', 'avatar.jpg', 's3');

The file is being sent normally to S3 but does not send with the correct mimetype. In the above example the file mimetype would be image/jpeg but when viewing directly by Amazon S3 panel the file is with mimetype application/octet-stream

This makes the file, when accessed, open the browser save (download) window and does not simply display the file as expected.

I couldn’t find a way to set mimetype or fix it in Bucket settings.

  • It seems that it is not Laravel’s problem to "send the mime" wrong, but the answer you get from Amazon is with this header.

  • Have you tried the test before the upload, request()->file('avatar')->getClientMimeType()?

  • Already yes, in Laravel is exhibiting with Mimetype right. Then I send and go to the Amazon console to click and see the image in the browser but then it opens for download.

  • So really, it seems to be setting on Amazon

  • If I send the file directly through the Amazon console mimetype is normal (image/jpeg) but not by Laravel.

  • You could open a Github Issue by reporting this problem! https://github.com/laravel/laravel

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.