Using image_tag and send_data

I am using image_tag to load an image that I've saved to the database
(using attachment_fu if you're curious but that's probably not
relevant here):

VIEW
<%= image_tag '/photo/get_image/5' %>

CONTROLLER
def get_image
  @photo=Photo.find(params[:id])
  send_data(DbFile.find(@photo.db_file_id).data,
                            :type => @photo.content_type,
                            :file_name =>
@photo.filename,
                            :disposition => 'inline')
end

The images I'm saving are less than 100kb and easily handled by my
mysql column of db_file.data which is declared MEDIUMBLOB.

My problem is that the view works perfectly in production but not at
all in development -- in development I just get a broken image graphic
with a box and a red x.

Any ideas on how to troubleshoot this? Since it doesn't seem to be my
code (it works fine in production) I'm at a loss on how to figure this
out.

I am using image_tag to load an image that I've saved to the database
(using attachment_fu if you're curious but that's probably not
relevant here):

I'd copy and paste that image link into the browser (ie yourserver,com/
photo/get_image/5) and see what the browser pulls out.

Fred

Thanks for the suggestion --
I get the same red box with the x.

Thanks for the suggestion --
I get the same red box with the x.

Do the logs indicate that an error occured ? If not and if you use the
tool of your choice to download the image, how do the bytes differ
from the bytes you would expect.

Fred

logs say that all is ok:
Sending data my_image.jpg
Completed in 0.09400 (10 reqs/sec) | Rendering: 0.00000 (0%) | DB:
0.08000 (85%) | 200 OK [http://localhost/photo/get_image/5]

Interesting question you ask about how do the bytes differ. I guess I
first need to find a "tool of my choice" other than my two browsers
(IE and Firefox) -- any suggestions?

logs say that all is ok:
Sending data my_image.jpg
Completed in 0.09400 (10 reqs/sec) | Rendering: 0.00000 (0%) | DB:
0.08000 (85%) | 200 OK [http://localhost/photo/get_image/5]

Interesting question you ask about how do the bytes differ. I guess I
first need to find a "tool of my choice" other than my two browsers
(IE and Firefox) -- any suggestions?

using the browser to save the image to disk would be one way.

Fred

i guess that's the point in that the browser is not displaying the
image -- it is just displaying the error gif, ie, a box with a red x
in it indicating that i can't load the image.

Fred, i really appreciate the time you're dedicating here...

Just tried something else --
Changed disposition to "attachment" and used Firefox to successfully
download the file. When I tried to open the file (in GIMP) I received
these error messages:
-- Premature end of JPEG file
-- Invalid JPEG file structure: missing SOS marker
So, I guess attachment_fu is not saving the files properly to my
db_file table...

Just tried something else --
Changed disposition to "attachment" and used Firefox to successfully
download the file. When I tried to open the file (in GIMP) I received
these error messages:
-- Premature end of JPEG file
-- Invalid JPEG file structure: missing SOS marker
So, I guess attachment_fu is not saving the files properly to my
db_file table...

that sounds like its getting truncated.

Fred

Yes -- seems like attachment_fu or mysql (?) might be truncating.
Weird though as the file size is not very large -- just 10kb. In my
experience, truncation occurs because you are handling large files...

Yes -- seems like attachment_fu or mysql (?) might be truncating.
Weird though as the file size is not very large -- just 10kb. In my
experience, truncation occurs because you are handling large files...

I suppose you need to pinpoint where it happens: before the image hit
your app, before attachment fu tried to save it, when mysql was given
the image, after retrieval from the database etc...

Fred

Yep -- guess I'll step through and research the various ways to check
the size of the data at each place. Thanks for your help!