Detect mime-type without download
-
If I have the URL of a file e.g. http://mysite.com/file.php?f=1 where I cannot see the extension of the file is it possible to determine the mime-type of the file without downloading it first?
-
If I have the URL of a file e.g. http://mysite.com/file.php?f=1 where I cannot see the extension of the file is it possible to determine the mime-type of the file without downloading it first?
You can download first several bytes and use Magic Numbers to detect type
Giorgi Dalakishvili #region signature my articles #endregion
-
You can download first several bytes and use Magic Numbers to detect type
Giorgi Dalakishvili #region signature my articles #endregion
But then I would need a lookup table, don't I? Is there no way this could be done with the .net framework? There are applications which have exactly this kind of functionality for example if you click on a download link with most browsers they display the mime-type without downloading. How is it done there?
-
But then I would need a lookup table, don't I? Is there no way this could be done with the .net framework? There are applications which have exactly this kind of functionality for example if you click on a download link with most browsers they display the mime-type without downloading. How is it done there?
Hi, normally a HTTP request performs a GET to receive the entire page. however you can also do a HEAD which requests just the head information, which often includes the mime-type, whereas the body is not transfered at all. I once did HTTP with the Socket class; I trust you can do it with HttpRequest too. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.