How does one reliably determine a file's type? File extension analysis is not acceptable. There must be a rubyesque tool similar to the UNIX file(1) command?
This is regarding MIME or content type, not file system classifications, such as directory, file, or socket.
...
I'm working with a snippet of code that recursively calls itself and tries to pull out a mime type part of "text/html" from an email (if it exists) for further processing. The "text/html" could exist inside other content such as "multipart/alternative" so I'm trying to find out if there is a defined hierarchy for email mime types. Anybod...
I'm downloading some images from a service that doesn't always include a content-type and doesn't provide an extension for the file I'm downloading (ugh, don't ask).
What's the best way to determine the image format in .NET?
The application that is reading these downloaded images needs to have a proper file extension or all hell breaks...
I am looking for a simple way to get a mime type where the file extension is incorrect or not given, something similar to this question only in .Net.
...
I have a script that works fine on my test server (using IIS6). The script processes an ajax request and sends a response with the following line:
header( 'application/javascript' );
But on my live server, this line crashes the page and causes a 500 error.
Do I need to allow PHP to send different MIME types in IIS7? If so, how do I do...
I want to override the JSON MIME type ("application/json") in Rails to ("text/x-json"). I tried to register the MIME type again in mime_types.rb but that didn't work. Any suggestions?
Thanks.
...
I used to be able to launch a locally installed helper application by registering a given mime-type in the Windows registry. This enabled me to allow users to be able to click once on a link to the current install of our internal browser application. This worked fine in Internet Explorer 5 (most of the time) and Firefox but now does not ...
I've got a php script. Most of the time the script returns html, which is working fine, but on one occasion (parameter ?Format=XML) the script returns XML instead of HTML.
Is there any way to change the returned mime type of the php output on the fly from text/html to text/xml or application/xml?
...
i want to find the mime-type for a given file extension on an IIS ASP.NET web-server from the code-behind file.
i want to search the same list that the server itself uses when serving up a file. This means that any mime types a web-server administrator has added to the Mime Map will be included.
i could blindly use
HKEY_CLASSES_ROOT\...
I am sure there is a simple answer to this one.
I have a docx file that I get an error when trying to download(document cannot be found).... .doc is fine .txt is also fine. I am sure this is just an iis setting, the permissions on the server are all the same for all files.
...
I'm programming something that allows users to store documents and pictures on a webserver, to be stored and retrieved later. When users upload files to my server, PHP tells me what filetype it is based on the extension. However, I'm afraid that users could rename a zip file as somezipfile.png and store it, thus keeping a zip file on m...
What is the MIME type of javascript?
More specifically, what is the right thing to put in the "type" attribute of a script tag? application/x-javascript and text/javascript seem to be the main contenders.
...
Some files are uploaded with a reported MIME type:
image/x-citrix-pjpeg
They are valid jpeg files and I accept them as such.
I was wondering however: why is the MIME type different?
Is there any difference in the format? or was this mimetype invented by some light bulb at citrix for no apparent reason?
...
Are there official MIME types for the .cs (C# source), .resx, .aspx, etc. files in a .NET project?
If no official types are defined, any recommendations on good MIME types? This will be exposed via Apache and the mod_dav_svn module when viewing a Subversion repository from a web browser, so anything that'll help Firefox et al render th...
MSTest produces an XML file with a .trx extension containing test results.
If I have a .trx file on a machine without Visual Studio installed, I get prompted to "Use the Web Service..." or "Select from a list...", which is expected.
If I have a .trx file on my development machine and I open it, it opens in Visual Studio, which is expect...
I have a resource handler that is Response.WriteFile(fileName) based on a parameter passed through the querystring. I am handling the mimetype correctly, but the issue is in some browsers, the filename comes up as Res.ashx (The name of the handler) instead of MyPdf.pdf (the file I am outputting). Can someone inform me how to change the n...
i have java web service, returns an Object contains couple of variables data, this web service being called in ASP code, but asp code always getting the Mime Type is "text/plain". even though I did setup the below
Response.ContentType = "application/xml"
and not parsing the web service results and error out type mismatch at loadXML.
Can ...
I've come across the problem where Excel will not play nice with UTF-8 encoded CSV files. See this related question on Stack Overflow.
I've followed the solution of exporting as UTF-16, however it seems that with UTF-16, the comma character doesn't work as a delimiter, only the tab character.
However I can't find anywhere what the corr...
I have a web API that returns python dictionaries or lists as a response that I eval() in python scripts that use the API, for completness I wanted to set a proper content-type but not sure what would be best to use "text/x-python" or maybe "application/python", or something else?
[edit] I'm also outputting JSON, I'm doing Python as an...
Here's the code:
render :file => @somedir + "/blah.xml"
...but the resulting MIME type is text/html when I check in FireBug. How do I specify a MIME type in this case?
...