Search code examples
thincorruption

Heroku image corruption


When uploading an image through git to heroku, the image is corrupted when it gets sent from the web server. I've been trying to fix it by going g rm --cached images/contact-me.png and then g add images/contact-me.png again, and then pushing.

Also;

xyz@co-data:~/labs/exposeit-site$ sha1sum images/contact-me.png 
2d319cd64e94afe7cdd169347653670a1dd82581  images/contact-me.png
xyz@co-data:~/labs/exposeit-site$ wget http://exposeit.herokuapp.com/images/contact-me.png
--2012-08-16 16:50:35--  http://exposeit.herokuapp.com/images/contact-me.png
Resolving exposeit.herokuapp.com (exposeit.herokuapp.com)... 50.19.121.246, 174.129.192.155, 184.73.155.93, ...
Connecting to exposeit.herokuapp.com (exposeit.herokuapp.com)|50.19.121.246|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1230115 (1.2M) [image/png]
Saving to: `contact-me.png'

100%[=================================================================================>] 1,230,115    963K/s   in 1.2s    

2012-08-16 16:50:36 (963 KB/s) - `contact-me.png' saved [1230115/1230115]

xyz@co-data:~/labs/exposeit-site$ sha1sum contact-me.png 
74d97745d35bb67e5517611b683ed461bd0c1686  contact-me.png

and

xyz@co-data:~/labs/exposeit-site$ g ls-files | grep contact-me
images/contact-me.png

Is this a problem of Heroku's?

Update:

Procfile:

web:  bundle exec thin start -R config.ru -e $RACK_ENV -p $PORT 

Solution

  • So the answer is that the thin gem has a bug that takes string length instead of length of the byte array that is the underlying image. Why it would first be converted to a string, I don't know.

    The solution is to add, to your Gemfile:

     gem 'rack-jekyll', :git => 'https://github.com/adaoraul/rack-jekyll.git', :require => 'rack/jekyll'
    

    ...and it will be downloaded from github rather than RubyGems.