citraL
citraL

Reputation: 1156

Paperclip+S3 works locally, not on Heroku

I configured my app to use S3 instead of local filesystem to store Paperclip files, when running in production. It works fine on my local machine in production (paperclip stores attachment in my S3 bucket).

On Heroku, it does not work, and the behaviour is weird:

If a user signs up and attach a profile picture and click submit, I got an error message:

1 error prohibited this user from being saved:
There were problems with the following fields: 

Avatar content type is not one of image/jpg, image/jpeg, image/png, image/gif 

whereas the uploaded image is in the proper format and is processed normally when running paperclip+s3 without Heroku...

Heroku logs say nothing...

I have set up heroku vars: heroku config:add bucket, access_key and secret_key.

Did I forget something ?

Many thanks for any help!!

Upvotes: 0

Views: 664

Answers (2)

citraL
citraL

Reputation: 1156

OK ... wrong guess ... it actually is not Heroku's fault, but Internet Explorer that converts 'image/jpeg' files into 'image/pjpeg' (even if the jpg is not progressive) and converts 'image/png' into 'image/x-png' content type ...

The tests done on my local machine were done with Mozilla, whereas the test on Heroku were done with IE, which explains why I thought it was Heroku ...

Everything runs fine with Chrome and Mozilla, but if you use Internet Explorer, be sure to add 'image/pjpeg', 'image/pjpg' and 'image/x-png' to the list of accepted image format in your validations!

Upvotes: 3

Neil Middleton
Neil Middleton

Reputation: 22238

This looks like the content type isn't being validated as correct for some reason. This should also fail if you run your application in production mode locally (thus ruling Heroku out of the equation)

Upvotes: 0

Related Questions