Rails on the Run

Rails experiments by Matt Aimonetti

Browsing Posts tagged mime type\’

Quick note to let you know that I updated mimetype_fu to actually get the mime type of a file using the file command on mac and linux. I still didn’t post an example since I’m planning on writing a patch for attachment_fu.

mimetype_fu/ is a new plugin I just wrote. It’s simple and it can be really useful if you need to get the mime type of a file already on your server.

During one of my project, I add to migrate old assets from a legacy system to a new Rails app. The new app uses attachment fu and even though techno weenie did an amazing job, attachmentfu validation is based on the content type. Afu gets the content type coming from the CGI query.

Unit test has a helper faking this process but in real life, if you use a Flash uploader (Flash doesn’t give you the proper mime type/content type) or if you want to migrate files, the attachment_fu validation won’t work for you.

The solution is simple: mimetype_fu/

mimetype_fu/ extends the File class and is really easy to use:

File.mime_type?(@file)

Check it out http://code.google.com/p/mimetype-fu/

Expect a post showing how a ninja would use the mimetypefu / attachmentfu combo :)