?
Solved

Getting Content-Type of a File

Posted on 2003-03-30
10
Medium Priority
?
265 Views
Last Modified: 2010-05-01
Hi experts,

I want to detect the content type of a file. I have a dll to "force download" of a file, but I couldn't figure out how to get the content-type. I imagine there should be a way to find it.

All answers are appreciated.

Thanks,
Igal NASSI
0
Comment
Question by:igalnassi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 

Expert Comment

by:pkmnfrk
ID: 8235282
Do you mean from a web site? Or off the HD?

If you mean HD, then you need to use an API call to find out. I don't know which one, but...

If you mean off the web, then you should be able to use the Mime type, but I don't usually do web stuff in VB.

Regardless, you could just check the extension of the file...
0
 

Author Comment

by:igalnassi
ID: 8235305
When I try to force the file to download from a web server, I should be sending the content-type in the response header. That's what I am trying to do. I don't think there would be any problems if I leave it blank, but I just don't want to take the chance for later versions of IE and netscape

Any other thoughts?
Igal
0
 

Expert Comment

by:Buchankas
ID: 8235664
Well, you could use a Sniffer, I use http://www.ufasoft.com/sniffer

Just Start the Sniffer, open your browser, and click the link to the file, then the HTTP headers should be shown in the Sniffer.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:igalnassi
ID: 8235845
Maybe I didn't quite explain correctly. My program is writing the header. It just needs to rearrange the content-type of the header with regards to the file it needs to send to the browser... Say: image/gif for .gif files. I am trying to automatically detect the type of the file from my program
0
 

Expert Comment

by:Buchankas
ID: 8235927
Hope this list helps, if you want to know any MIME type unlisted here let me know.



# Usual MIME types



text/plain                   txt cgi java

text/html                    htm html shtml

application/octet-stream     bin class

application/postscript       ps eps ai

application/pdf              pdf



# Image specific MIME types



image/x-xbitmap              xbm

image/x-xpixmap              xpm

image/x-xwindowdump          xwd

image/x-xbitmap              xbm

image/x-cmu-raster           ras

image/x-portable-anymap      pnm

image/x-portable-bitmap      pbm

image/x-portable-graymap     pgm

image/x-rgb                  rgb

image/gif                    gif

image/jpeg                   jpeg jpe jpg

image/tiff                   tiff tif


 
 
 # Audio video specific MIME types



audio/basic                 au snd

audio/x-wav                 wav

video/mpeg                  mpeg mpe mpg

video/quicktime             mov qt

video/x-sgi-movie           movie

application/java            java

application/x-csh           csh

application/x-sh            sh

application/x-tcl           tcl

application/x-tex           tex

application/x-latex         latex

application/x-texinfo       texinfo texi

application/zip             zip

application/x-bcpio         bcpio

application/x-cpio          cpio

application/x-shar          shar

application/x-tar           tar

application/x-dvi           dvi

application/x-hdf           hdf

application/x-x509-ca-cert  cer cert



# zip files



multipart/x-zip             zip

 
0
 

Author Comment

by:igalnassi
ID: 8236159
This list will help if I want to HARD-CODE the types. Is there a way to find it in the code?

In other words I want a function like this:

Private Function getMimeType(ByVal strExtension As String) As String




End Function
0
 

Author Comment

by:igalnassi
ID: 8236160
This list will help if I want to HARD-CODE the types. Is there a way to find it in the code?

In other words I want a function like this:

Private Function getMimeType(ByVal strExtension As String) As String




End Function
0
 

Author Comment

by:igalnassi
ID: 8236167
Sorry pressed submit by accident...

The inside of the function reads...

Private Function getMimeType(ByVal strExtension As String) As String

   Goto the registry or whereever you can find this info
   Find the mime-type
   getMimeType = mime-type just found

End Function


I don't want to hard code the MIME-TYPES in the function. I want to look for them from their source.
0
 

Accepted Solution

by:
pkmnfrk earned 150 total points
ID: 8241261
not really. The mime type was important for Netscape a while back, but is really redundant now. IE and NS both look in the registry for information on how to deal with a file. It should be quite safe to leave it blank.
0
 

Expert Comment

by:CleanupPing
ID: 8531322
Hi igalnassi,
This old question (QID 20567997) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question