Browsing projects by Tag(s)

Select a tag to browse associated projects and drill deeper into the tag cloud.

Showing page 1 of 1

What is it?Some great Rails plugins like attachment_fu use the content type/mime type of a file to validate the instance of an object. The plugin usually gets the mime type using the CGI request, however, if the file is already in the system, this approach won't work. Adobe Flash is also known ... [More] not to send the proper mime type. As an alternative, I wrote mimetype_fu, a simple plugin which will try to retrieve the mimetype. Note that mimetype_fu used to only looks at the extension to define its mime type, that's not true anymore, this nifty little plugin uses your os to open the file and check on the header for the mime type :) (sorry windows users, mimetype will only check on the file extension) How to use it?mimetype_fu extends the File class: >> @file = File.open("#{RAILS_ROOT}/test/test.mp3") => # >> File.mime_type?(@file) => "audio/mpeg" You can also get the mime type of the file by only passing its path: >> File.mime_type?('test.jpg') => "image/jpeg" How to install mimetype_fuscript/plugin install http://mimetype-fu.googlecode.com/svn/trunk/ (don't forget to rename the plugin folder) You can also use svn: cd vendor/plugins svn checkout http://mimetype-fu.googlecode.com/svn/trunk/ mimetype-fu FYI: mimetype-fu is moving to github: http://github.com/matta/mimetype-fu/tree Feel free to fork mimetype-fu and send me a pull request [Less]

0
 
  0 reviews  |  0 users  |  82 lines of code  |  0 current contributors  |  Analyzed 2 days ago
 
 

HTTP-PHP is a fully featured HTTP library for PHP5, allowing you to work with HTTP requests and responses, their headers, redirection and forwarding, content and content negotiation, charsets, MIME Types, and more.

0
 
  0 reviews  |  0 users  |  0 current contributors  |  Analyzed 5 days ago
 
 
 
 

Creative Commons License Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.