Board index » Web Programming » Mime type

Mime type

Web Programming270
What class is available to me to "discover" the mime type of a file that I

want to stream?

I must be having a brain fart today as I cannot find anything that does

this.



Thanks for your pointers.


-
 

Re:Mime type

Humm. I don't know if it exists in the FCL but keep in mind that you won't

have necessarily this information server side.



My personal preference would be rather to have this as part of my data (as a

table perhaps) rather than to have to do some server configuration to

declare this...



Patrice



--



"Johan Pingree" <spamblocked@webequipped.com>a écrit dans le message de

Quote
What class is available to me to "discover" the mime type of a file that I

want to stream?

I must be having a brain fart today as I cannot find anything that does

this.



Thanks for your pointers.









-

Re:Mime type

Well IMHO this should be possible. If I have a file on the system locally,

lets say it is an excel file. I should be able to get a mime mapping/content

type that would equal: application/vnd.ms-excel OR if it is a bitmap file I

should be able to get: image/x-bitmap



This is, I discovered, possible, but by no means efficient, see:

System.Net.FileWebResponse.ContentType

It is like going in through the out door!



I guess I will have to manage this in my own mapping table for now.

Hopefully some at Microsoft will pick up on this and address it.



"Patrice" <nobody@nowhere.com>wrote in message

Quote
Humm. I don't know if it exists in the FCL but keep in mind that you won't

have necessarily this information server side.



My personal preference would be rather to have this as part of my data (as

a

table perhaps) rather than to have to do some server configuration to

declare this...



Patrice



--



"Johan Pingree" <spamblocked@webequipped.com>a écrit dans le message de

news:eAdlYX$nEHA.2684@TK2MSFTNGP11.phx.gbl...

>What class is available to me to "discover" the mime type of a file that

>I

>want to stream?

>I must be having a brain fart today as I cannot find anything that does

>this.

>

>Thanks for your pointers.

>

>









-

Re:Mime type

If you really want you could use interop to read mime types.



Keep in mind that you are server side. If Excel is not installed you won't

know its mimetype. Do you want to install each and every application just to

be able to download its files ?

Another option would be then to write just the appropriate info to the

registry and finally it's easier to keep your own table.



What would be great would be rather to use a web service and keep the

ability to supplant a particular mimetype if needed (sometimes the mimetype

may also not be the one you want).



Hope it clarifies a bit whay I'm reluctant to get this info from the system.



Patrice





--



"Johan Pingree" <spamblocked@webequipped.com>a écrit dans le message de

Quote
Well IMHO this should be possible. If I have a file on the system locally,

lets say it is an excel file. I should be able to get a mime

mapping/content

type that would equal: application/vnd.ms-excel OR if it is a bitmap file

I

should be able to get: image/x-bitmap



This is, I discovered, possible, but by no means efficient, see:

System.Net.FileWebResponse.ContentType

It is like going in through the out door!



I guess I will have to manage this in my own mapping table for now.

Hopefully some at Microsoft will pick up on this and address it.



"Patrice" <nobody@nowhere.com>wrote in message

news:elbQeHAoEHA.3668@TK2MSFTNGP15.phx.gbl...

>Humm. I don't know if it exists in the FCL but keep in mind that you

won't

>have necessarily this information server side.

>

>My personal preference would be rather to have this as part of my data

(as

>a

>table perhaps) rather than to have to do some server configuration to

>declare this...

>

>Patrice

>

>--

>

>"Johan Pingree" <spamblocked@webequipped.com>a écrit dans le message de

>news:eAdlYX$nEHA.2684@TK2MSFTNGP11.phx.gbl...

>>What class is available to me to "discover" the mime type of a file

that

>>I

>>want to stream?

>>I must be having a brain fart today as I cannot find anything that does

>>this.

>>

>>Thanks for your pointers.

>>

>>

>

>









-

Re:Mime type

Yes, I will ponder creating a soap service and for now I will use a database

table to map them.

To give you an brief on why I want this: I am developing a web based dotNet

webmail application. Recieved email often has attachments. I want to stream

those attachement to the user when they request an attached file. I would

like to be able to set the response content-type of the file going to the

end user.



I do appreciate you taking the time to answer - thank you.



Johan.







"Patrice" <nobody@nowhere.com>wrote in message

Quote
If you really want you could use interop to read mime types.



Keep in mind that you are server side. If Excel is not installed you won't

know its mimetype. Do you want to install each and every application just

to

be able to download its files ?

Another option would be then to write just the appropriate info to the

registry and finally it's easier to keep your own table.



What would be great would be rather to use a web service and keep the

ability to supplant a particular mimetype if needed (sometimes the

mimetype

may also not be the one you want).



Hope it clarifies a bit whay I'm reluctant to get this info from the

system.



Patrice





--



"Johan Pingree" <spamblocked@webequipped.com>a écrit dans le message de

news:OCVfdTAoEHA.132@TK2MSFTNGP09.phx.gbl...

>Well IMHO this should be possible. If I have a file on the system

>locally,

>lets say it is an excel file. I should be able to get a mime

mapping/content

>type that would equal: application/vnd.ms-excel OR if it is a bitmap file

I

>should be able to get: image/x-bitmap

>

>This is, I discovered, possible, but by no means efficient, see:

>System.Net.FileWebResponse.ContentType

>It is like going in through the out door!

>

>I guess I will have to manage this in my own mapping table for now.

>Hopefully some at Microsoft will pick up on this and address it.

>

>"Patrice" <nobody@nowhere.com>wrote in message

>news:elbQeHAoEHA.3668@TK2MSFTNGP15.phx.gbl...

>>Humm. I don't know if it exists in the FCL but keep in mind that you

won't

>>have necessarily this information server side.

>>

>>My personal preference would be rather to have this as part of my data

(as

>>a

>>table perhaps) rather than to have to do some server configuration to

>>declare this...

>>

>>Patrice

>>

>>--

>>

>>"Johan Pingree" <spamblocked@webequipped.com>a écrit dans le message

>>de

>>news:eAdlYX$nEHA.2684@TK2MSFTNGP11.phx.gbl...

>>>What class is available to me to "discover" the mime type of a file

that

>>>I

>>>want to stream?

>>>I must be having a brain fart today as I cannot find anything that

>>>does

>>>this.

>>>

>>>Thanks for your pointers.

>>>

>>>

>>

>>

>

>









-

Re:Mime type

FindMimeFromData() is a method exposed by urlmon.dll which means you need to

Pinvoke it. (as patrice said).



here www.pinvoke.net/default.aspx/urlmon.FindMimeFromData">www.pinvoke.net/default.aspx/urlmon.FindMimeFromData is the code

showing you how to use it. :)





--

Girish Bharadwaj

msmvps.com/gbvb">msmvps.com/gbvb

"Patrice" <nobody@nowhere.com>wrote in message

Quote
If you really want you could use interop to read mime types.



Keep in mind that you are server side. If Excel is not installed you won't

know its mimetype. Do you want to install each and every application just

to

be able to download its files ?

Another option would be then to write just the appropriate info to the

registry and finally it's easier to keep your own table.



What would be great would be rather to use a web service and keep the

ability to supplant a particular mimetype if needed (sometimes the

mimetype

may also not be the one you want).



Hope it clarifies a bit whay I'm reluctant to get this info from the

system.



Patrice





--



"Johan Pingree" <spamblocked@webequipped.com>a écrit dans le message de

news:OCVfdTAoEHA.132@TK2MSFTNGP09.phx.gbl...

>Well IMHO this should be possible. If I have a file on the system

locally,

>lets say it is an excel file. I should be able to get a mime

mapping/content

>type that would equal: application/vnd.ms-excel OR if it is a bitmap

file

I

>should be able to get: image/x-bitmap

>

>This is, I discovered, possible, but by no means efficient, see:

>System.Net.FileWebResponse.ContentType

>It is like going in through the out door!

>

>I guess I will have to manage this in my own mapping table for now.

>Hopefully some at Microsoft will pick up on this and address it.

>

>"Patrice" <nobody@nowhere.com>wrote in message

>news:elbQeHAoEHA.3668@TK2MSFTNGP15.phx.gbl...

>>Humm. I don't know if it exists in the FCL but keep in mind that you

won't

>>have necessarily this information server side.

>>

>>My personal preference would be rather to have this as part of my data

(as

>>a

>>table perhaps) rather than to have to do some server configuration to

>>declare this...

>>

>>Patrice

>>

>>--

>>

>>"Johan Pingree" <spamblocked@webequipped.com>a écrit dans le message

de

>>news:eAdlYX$nEHA.2684@TK2MSFTNGP11.phx.gbl...

>>>What class is available to me to "discover" the mime type of a file

that

>>>I

>>>want to stream?

>>>I must be having a brain fart today as I cannot find anything that

does

>>>this.

>>>

>>>Thanks for your pointers.

>>>

>>>

>>

>>

>

>









-

Re:Mime type

There are a limited number of MIME Types, in the few hundreds, I believe. If

you want to get the MIME type for a file, you can do it by extension. Just

do a little research on MIME types, figure out what file extensions you are

going to be using, and create a table to hold the file extensions and their

associated MIME types. Then refer to that table when you need to. That's

pretty much how IIS does it, and pretty much how browsers do it.



--

HTH,

Kevin Spencer

.Net Developer

Microsoft MVP

I get paid good money to

solve puzzles for a living



"Johan Pingree" <spamblocked@webequipped.com>wrote in message

Quote
Well IMHO this should be possible. If I have a file on the system locally,

lets say it is an excel file. I should be able to get a mime

mapping/content

type that would equal: application/vnd.ms-excel OR if it is a bitmap file

I

should be able to get: image/x-bitmap



This is, I discovered, possible, but by no means efficient, see:

System.Net.FileWebResponse.ContentType

It is like going in through the out door!



I guess I will have to manage this in my own mapping table for now.

Hopefully some at Microsoft will pick up on this and address it.



"Patrice" <nobody@nowhere.com>wrote in message

news:elbQeHAoEHA.3668@TK2MSFTNGP15.phx.gbl...

>Humm. I don't know if it exists in the FCL but keep in mind that you

won't

>have necessarily this information server side.

>

>My personal preference would be rather to have this as part of my data

(as

>a

>table perhaps) rather than to have to do some server configuration to

>declare this...

>

>Patrice

>

>--

>

>"Johan Pingree" <spamblocked@webequipped.com>a écrit dans le message de

>news:eAdlYX$nEHA.2684@TK2MSFTNGP11.phx.gbl...

>>What class is available to me to "discover" the mime type of a file

that

>>I

>>want to stream?

>>I must be having a brain fart today as I cannot find anything that does

>>this.

>>

>>Thanks for your pointers.

>>

>>

>

>









-