The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Type I and Type II Errors - The Heart of Event Processing iBot Complex Event Processing RSS News 0 12-05-2007 02:50 PM
array type has incomplete element type jaganadh High Level Programming 1 07-24-2007 12:54 AM
Lynx - Downloading - extension handling - changing mime type? yitzle UNIX for Dummies Questions & Answers 2 10-17-2006 08:46 PM
human readable format of file size when doing ls –l umen UNIX for Dummies Questions & Answers 1 09-28-2005 06:20 AM
How to Set Mime type to mailx suneel UNIX for Advanced & Expert Users 1 07-08-2003 08:17 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-21-2007
Registered User
 

Join Date: Mar 2007
Posts: 1
Human readable type vs MIME type detection using file

Hi

I am currently using the file command to detect the file type of a number of documents I have, including ODT, PDF and MSWord to name but a few. Additionally this list of files has no extension and so I must go on the file type alone to work out which file is of what type.

I can use the file command successfully to obtain the human readable file type;
e.g. ODT = OpenDocument Text, PDF = PDF Document, version ..., DOC = MS Office Document but when I specify the --mime flag I get alternative values. For ODT = OpenDocument Text = application/x-zip but it should really be application/vnd.oasis.opendocument.text or so I can see in the /usr/share/file/magic file. I have had the same problem with multimedia files as well, especially video where I get the correct human readable type every time but the mime type is nearly always reported as application/octet-stream.

The reason I need the mime type is that I would like to stream some of these documents to a client's web browser and I need to tell the browser the MIME type of the file.

$ file --version reports the following
file-4.17
magic file from /etc/magic:/usr/share/file/magic

Is there some way I can get the correct MIME type? Should I be using file or is there another command I should be using? Any help would be much appreciated.

Last edited by spauldingsmails; 03-21-2007 at 08:50 PM.
Reply With Quote
Google UNIX.COM
Forum Sponsor
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0