Is mime content type case sensitive?

I've been working with attachment_fu and have found some curious behavior when using firefox as a browser. I've been following the straightforward example that is referenced in attachment_fu's readme.

Simply put, I have a view/new... that accepts an image file and uses attachment_fu in the model to store the file and thumbnail on the filesystem. The view/index... puts up the thumbnails as "link_to" pointing at their respective full size images. I've been feeding in jpeg image files and using rmagick as the image processor.

All works as advertised as long as the filename's type is lowercase. i.e.:    file.jpg === good    file.JPG === bad

What happens in the good case is selecting the thumbnail link causes the fullsize image to display in the window that previously showed the view/index...

What happens in the bad case is selecting the link causes a dialog box to pop up asking me what I want to do with this "JPEG Picture" content. If I select to display it in firefox it is first downloaded and then displayed in a new window.

NOTE: The file_thumb.JPG which corresponds to the (bad) file.JPG displays normally on the view/index... page.

NOTE: Mugshot.find(:all) shows all records (good and bad types) to have "image/jpeg" as content_type.

NOTE: All images (good and bad) open normally when accessed directly from the filesystem. i.e.: file://.../public/mugshots/0000/0001/file.JPG works http://localhost…/0001/file.JPG doesn't

Since I cannot reproduce this problem with either Opera, Safari, or IE (go figure:-), I've opened an issue with the firefox folks.

My question here is what is the RoR server handing firefox that is causing it to trip up?

Environment: Ruby version 1.8.7 (powerpc-darwin9.6.0) RubyGems version 1.3.1 Rack version 1.0 bundled Rails version 2.3.2 Active Record version 2.3.2 Action Pack version 2.3.2 Active Resource version 2.3.2 Action Mailer version 2.3.2 Active Support version 2.3.2 Application root /Users/rick/example/mugshots Environment development Database adapter sqlite3 Database schema version 20090424050842

Run either Thin or Webrick - makes no difference Grab current attachment_fu from github

I'm ready to sit naked in the dirt and wait for inspiration - not a pretty sight I'm sure.

Rick Lloyd wrote:

Simply put, I have a view/new... that accepts an image file and uses attachment_fu in the model to store the file and thumbnail on the filesystem. The view/index... puts up the thumbnails as "link_to" pointing at their respective full size images. I've been feeding in jpeg image files and using rmagick as the image processor.

All works as advertised as long as the filename's type is lowercase. i.e.:    file.jpg === good    file.JPG === bad

I'm not completely sure how different browsers treat this, but I do know this: On many file systems (expecially UNIX based ones) "file.jpg" and "file.JPG" are different files entirely since the file system itself is case sensitive.

AFAIK according to W3C spec, mime Content-Type header (type/subtype) is not case sensitive. That is, image/jpeg, Image/Jpeg and image/JPEG - all mean the same.

I agree with Robert, I guess the issue you are having is platform and implementation specific.

All works as advertised as long as the filename’s type is lowercase. i.e.: file.jpg === good file.JPG === bad

i think you are talking about file extensions, not mime type. mime content-type for jpeg files is image/jpeg (type is image and subtype is jpeg not jpg) but they can have .jpeg and .jpg file extensions. extensions are case sensitive in *nix based systems as their file system itself is case sensitive.

Yes I agree, my problem is with file extensions and is platform specific but I'ld like to understand it so I can get a fix.

So in the time since I wrote the original post, I've done some more testing. I've run now with the following combinations:

Browsers: Firefox (2.0.0.9, 3.0.8, 3.0.10), Safari3.2.1, Opera9.6.4, IE5 Plugins: attachment_fu, paperclip Servers: webrick, thin, mongrel (ruby 1.8.7 only) Ruby: 1.8.7 and 1.9.2dev Rails: 2.3.2 OS: OSX 10.5.6

The problem is specific to Firefox and displays only when using:

<%= link_to image_tag(photo.public_filename(:thumb)), photo.public_filename %>

in attachment_fu, or:

<%= link_to image_tag(@photo.snap.url(:medium)), @photo.snap.url %>

in paperclip.

If the photo is named "photo.jpg" all works as expected.

If the photo is named "photo.JPG" the link image on the from end of the link displays correctly even though it's name is something like "photo_thumb.JPG". Following the link however causes firefox to request an action to correspond to content type "JPEG Picture".

I've also done a simple test where all actions are local, i.e. from file:// rather than http:// locations. All extensions behave correctly.

Anyone out there want to test this out on a different OS? browser? server?

I just looked at the headers associated with my problem and here's what I saw: