I'm having trouble serving images which I have saved as db_files with attachment_fu. I use this code to serve the images:
Controller -- class PhotoController < ApplicationController def image @photo=Photo.find(params[:id]) send_data(DbFile.find(@photo.db_file_id).data, :type => @photo.content_type, :filename => @photo.filename, :disposition => 'inline') end end
View -- <%=image_tag(url_for(:controller=>'photo', :action=>'image', :id=>@photo))%>
On the web page, I just get a box with a red X in it where the image should be. This occurs only on my development machine (windows XP) but not on my production machine (linux). On my production machine all works perfectly.
To debug, I switched :disposition=>'inline' to :disposition=>'attachment', downloaded the file, and opened with GIMP. GIMP reports these errors: "Premature end of JPEG file" and "Invalid JPEG file structure -- missing SOS marker".
Does anyone have any ideas?
I am using ImageScience as my processor.
(BTW, I have already implemented the attachment_fu_patch which fixes various windows/attachment_fu problems described here -- http://epirsch.blogspot.com/2008/01/fixing-attachmentfu-on-windows-like.html.)