getting mimetype of a file

R

Ryan Paul

is there any way to determine the mimetype of a file using ruby?

TIA

--SegPhault

=P just realized I sent this to the wrong list. as long as I'm here... how
is it done in python?
 
C

Christos TZOTZIOY Georgiou

is there any way to determine the mimetype of a file using ruby?
[snip]
=P just realized I sent this to the wrong list. as long as I'm here... how
is it done in python?

The mimetypes.py module in the standard library is your friend.
 
M

Matteo Merli

Christos said:
is there any way to determine the mimetype of a file using ruby?
[snip]
=P just realized I sent this to the wrong list. as long as I'm here... how
is it done in python?

The mimetypes.py module in the standard library is your friend.

A more effective approach would be to use the "magic" module that come
with the "file" utility (it is present in the sources, but not built by
default).
This way you can perform a fine-grained recognition of files..

Matteo
 
C

Christos TZOTZIOY Georgiou

Christos said:
is there any way to determine the mimetype of a file using ruby? [snip]
=P just realized I sent this to the wrong list. as long as I'm here... how
is it done in python?

The mimetypes.py module in the standard library is your friend.

....if one wants to judge by the filename only (I wasn't clear earlier).
A more effective approach would be to use the "magic" module that come
with the "file" utility (it is present in the sources, but not built by
default).
This way you can perform a fine-grained recognition of files..

Indeed. One such attempt (mine) to use the "magic" file from python can
be found here:

http://www.sil-tec.gr/~tzot/python/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top