# How do you determine the MIME type for a file?

**URL:** <https://www.ruby-forum.com/t/how-do-you-determine-the-mime-type-for-a-file/110148>\
**Category:** Rails\
**Created:** [July 23, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/how-do-you-determine-the-mime-type-for-a-file/110148 "2007-07-23T20:19:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlorimor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@rlorimor](https://www.ruby-forum.com/u/rlorimor)\
**Post date:** [July 23, 2007, 8:19pm UTC](https://www.ruby-forum.com/t/how-do-you-determine-the-mime-type-for-a-file/110148/1 "2007-07-23T20:19:25Z")

</div>

What’s the best way to determine the mime type of a file given it’s  
path?

---

<div class="post-metadata">

**Author:** ![rlorimor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/96bed5/32.png) [@rlorimor](https://www.ruby-forum.com/u/rlorimor)\
**Post date:** [July 23, 2007, 9:20pm UTC](https://www.ruby-forum.com/t/how-do-you-determine-the-mime-type-for-a-file/110148/2 "2007-07-23T21:20:56Z")

</div>

use the mime\_types gem

Adam
