# Content\_type from a local file?

**URL:** <https://www.ruby-forum.com/t/content-type-from-a-local-file/108563>\
**Category:** Rails\
**Created:** [July 4, 2007, 7:05pm UTC](https://www.ruby-forum.com/t/content-type-from-a-local-file/108563 "2007-07-04T19:05:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevorturk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/278dde/32.png) [@trevorturk](https://www.ruby-forum.com/u/trevorturk)\
**Post date:** [July 4, 2007, 7:05pm UTC](https://www.ruby-forum.com/t/content-type-from-a-local-file/108563/1 "2007-07-04T19:05:20Z")

</div>

I’m using a Rake task to add local files into a database designed for  
use with attachment\_fu.

[http://eldorado.googlecode.com/svn/trunk/db/migrate/039\_create\_avatars.rb](http://eldorado.googlecode.com/svn/trunk/db/migrate/039_create_avatars.rb)  
[http://eldorado.googlecode.com/svn/trunk/lib/tasks/import\_files.rake](http://eldorado.googlecode.com/svn/trunk/lib/tasks/import_files.rake)

So, attachment\_fu has a “content\_type” field, which apparently is  
receiving that information from the browser…?

I’m trying to figure out if there is a way to get the content\_type of a  
file (e.g. ‘image/png’) that you’ve already got in your file-system. I  
can’t find anything about this in the Pickaxe, or by looking at the  
attachment\_fu plugin.

Any help very much appreciated!

---

<div class="post-metadata">

**Author:** ![trevorturk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/278dde/32.png) [@trevorturk](https://www.ruby-forum.com/u/trevorturk)\
**Post date:** [July 5, 2007, 4:22am UTC](https://www.ruby-forum.com/t/content-type-from-a-local-file/108563/2 "2007-07-05T04:22:20Z")

</div>

read the following post:

[http://www.railsweenie.com/users/2237/posts](http://www.railsweenie.com/users/2237/posts)

contains information about using the mime-types plugin to determine  
content\_type outside of the CGI library

Mike

---

<div class="post-metadata">

**Author:** ![trevorturk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/278dde/32.png) [@trevorturk](https://www.ruby-forum.com/u/trevorturk)\
**Post date:** [July 5, 2007, 4:26am UTC](https://www.ruby-forum.com/t/content-type-from-a-local-file/108563/3 "2007-07-05T04:26:52Z")

</div>

Terrific. Thanks very much!
