send_data with jpeg not working

I'm a newbie having trouble using send_data to send a jpeg file to the browser for display in an html img tag. This is the relevant code

def retrieve   @photo = Photo.find(params[:id])   send_data File.read(@photo.abs_img_path), :type => "image/ jpeg", :disposition => "inline" end

def download   @photo = Photo.find(params[:id])   send_file @photo.abs_img_path, :type => "image/jpeg", :filename => @photo.filename end

In my html.erb file I have the following tags:

<%= image_tag retrieve_photo_path(@photo) %> ..... <%= link_to "Download photo", download_photo_path(@photo) %>

I get a broken image in the browser. I see the html src correctly has the image tag <img src="photos/5/retrieve"/>. If I browse directly to "http://www.myapp.com/photos/5/retrieve&quot;, I just get the text "http:// www.myapp.com/photos/5/retrieve" spit back to the browser (I'm using Firefox). The download link works perfectly, so I know the routes work, the file exists and isn't corrupted, etc.

What am I missing with that send_data method? I'm using InstantRails on Win XP, updated to Rails 2.3.4, Ruby 1.8.6. I've been banging my head on this for a little while and I have a feeling I'm missing something obvious...

A little more info now... when I simulate the img tag request by typing www.myapp.com/photos/5/retrieve into the browser, I get the following line in my Apache access.log:

"GET /photos/5/retrieve HTTP/1.1" 304 0

whereas if I type in the url to one of my public images (www.myapp.com/ images/logo.jpg), the logo image displays and I get the following line in the Apache log:

"GET /images/logo.jpg HTTP/1.1" 200 30796

Clicking the download link (which is successful) produces a similar access.log entry with status code 200. A cursory search on HTTP status codes shows me 200 means OK and 304 means "Not Modified". Does this have something to do with caching -- is Apache thinking it has the requested data cached?

okay here's the solution (graciously provided by someone on stackoverflow.com) --

I modified the retrieve action in my controller to use File.open first:

def retrieve   @photo = Photo.find(params[:id])   File.open(@photo.abs_img_path, 'rb') do |f|     send_data f.read, :type => "image/jpeg", :disposition => "inline"   end end