Hi,
I'm trying to figure out a way to get the same information that you would
from the "content_type" method of the CGI class.
The problem is that I want to get this info from a file already in the
filesystem locally. For example, using ruby's File.size would give me the
same info as an uploaded CGI object's size method. However, the file class'
"ftype" method only gives things like "file", "directory", etc whereas CGI
"content_type" (what I want) gives things like "image/png".
File class: http://www.ruby-doc.org/core/classes/File.html#M000016
CGI class: http://www.ruby-doc.org/stdlib/libdoc/cgi/rdoc/classes/CGI.html
···
--
Respectfully:
Larry Diehl
I think this is as close are you are going to get: http://raa.ruby-lang.org/project/filemagic/
You have to remember that MIME types are placed in the headers by the web-server.
···
On Jun 23, 2006, at 10:24 AM, Larrytheliquid wrote:
Hi,
I'm trying to figure out a way to get the same information that you would
from the "content_type" method of the CGI class.
The problem is that I want to get this info from a file already in the
filesystem locally. For example, using ruby's File.size would give me the
same info as an uploaded CGI object's size method. However, the file class'
"ftype" method only gives things like "file", "directory", etc whereas CGI
"content_type" (what I want) gives things like "image/png".
File class: http://www.ruby-doc.org/core/classes/File.html#M000016
CGI class: http://www.ruby-doc.org/stdlib/libdoc/cgi/rdoc/classes/CGI.html
--
Respectfully:
Larry Diehl
Logan,
Thanks, yeah the problem was that the mime type isn't part of a file.
I found MIME::Types <http://rubyforge.org/projects/mime-types/> and it does
just what I need.
Thanks.
···
On 6/23/06, Logan Capaldo <logancapaldo@gmail.com> wrote:
On Jun 23, 2006, at 10:24 AM, Larrytheliquid wrote:
> Hi,
>
> I'm trying to figure out a way to get the same information that you
> would
> from the "content_type" method of the CGI class.
> The problem is that I want to get this info from a file already in the
> filesystem locally. For example, using ruby's File.size would give
> me the
> same info as an uploaded CGI object's size method. However, the
> file class'
> "ftype" method only gives things like "file", "directory", etc
> whereas CGI
> "content_type" (what I want) gives things like "image/png".
>
> File class: http://www.ruby-doc.org/core/classes/File.html#M000016
> CGI class: http://www.ruby-doc.org/stdlib/libdoc/cgi/rdoc/classes/
> CGI.html
>
> --
> Respectfully:
> Larry Diehl
I think this is as close are you are going to get: http://raa.ruby-
lang.org/project/filemagic/
You have to remember that MIME types are placed in the headers by the
web-server.
--
Respectfully:
Larry Diehl