mime-types

What is the correct way to determine the type of a file returned by a web server?

I've always believed that the HTTP Content-Type should correctly identify the contents of a returned resources. I've recently noticed a resource from google.com with a filename similar to /extern_chrome/799678fbd1a8a52d.js that contained HTTP headers of: HTTP/1.1 200 OK Expires: Mon, 05 Sep 2011 00:00:00 GMT Last-Modified: Mon, 07 Sep ...

How can I get the mime type in PHP

I am writing a script and I need to correctly (I think some mime types can be different from their extensions) get the mime types of files (the files can be of any type). Web hosting company in use does not have mime_content_type() and is still (don't know which year they will be fixing it) promising to fix the PECL alternative. Which ...

rails controller respond_to format with two extensions (e.g. tar.gz)

Is there a mechanism or accepted approach for responding to requests that have a more complicated format extension? My specific scenario involves returning a plist file. However, I need to sometimes return this file as an XML plist file and sometimes as a binary plist file. I thought that URLs composed like /resources.xml.plist and /re...

MIME Types and exporting to different applications (excel, word , pdf ...etc etc)

i was wondering what really happen behind the scene when i write a file with mime type like this application/vnd.ms-excel i mean i export to excel like this: gridView.Page.Response.Clear(); gridView.Page.Response.Buffer = true; gridView.Page.Response.AddHeader("content-disposition", "attachment;filename=G...

ActiveMailer test pass when run through ruby but not when rake test:units

Hi All - I'm having trouble with an activemailer test I created. When I run the test directly with ruby, the test passes. When I run all the unit tests they fail, because the way the message is encoded changed. Running the test from rake test:units breaks the email into multiple mimeparts, that do not exist when running ruby unit/mail...

Ruby on Rails' respond_to causing strange error

There is another respond_to for the usual case, and a special case when a param[:top] is passed in, so there is another respond_to earlier in the code: respond_to do |format| format.html { render :top_page_analytics } format.json { render :json => @analytics } format.xml { render :xml => @analytics } ...

Why might Chrome return an incorrect MIME type error for one of my JS files when they are all served the same way?

I'm getting an error reading one of my JavaScript files ("Resource interpreted as script but transferred with MIME type text/html.") from Google Chrome. The other three JS files that my page calls load just fine, and I'm confused about what is causing this problem since they are all marked up in exactly the same way (and each has a "typ...

Detecting a file mimetype in coldfusion that's already uploaded on the server

I am attempting to detect the file type of a library of files on our webserver as we are implementing code that is designed to stream files to the browser securely. Previously, the files were being stored and presented to users via a direct href. I have attempted to do this 3 different ways, all on my local machine (which is NOT a simu...

Which MIME type should I use to serve XHTML5 to IE7 and IE8?

I want to use XHTML5 but apparently they two browsers don't accept the application/xhtml+xml MIME type. I read that they will accept text/xml (or application/xml not sure) but it is kind of hackish. So I was wondering if I should just serve HTML5 to IE7 and IE8? Please don't go on talking about XHTML vs HTML advantages. I know. ...

websvn is not ignoring mime type

I am using websvn to see svn revision comparison. I uncommented $config->ignoreSvnMimeTypes(); to my config.php, but it seems not to work: Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream What am I missing? ...

What is a MIME type?

Hi Guys; I have been reading about how to build plug-ins and this "MIME type" keeps getting discussed in it, i have tried to look into and know that its Multipurpose Internet Mail Extensions (MIME) but no suitable explanation of how it relates to browser plug-ins as in what i need to know about it for building plug-ins is provided, plea...

Reason ForceType application/x-httpd-php on .htaccess not working at all

I have tried to use: .htaccess <Files client> ForceType application/x-httpd-php </Files> client file <?php echo "FOO BAR"; ?> Just to test, but the server is not parsing the client file, it just serves it up as a file download. I tried SetHandler also without luck. UPDATE I'm using MediaTemple and the have there own way o...

determining whether a MIME type is binary or text-based

Is there a library which allows determining whether a given content type is binary or text-based? Obviously text/* is always textual, but for things like application/json, image/svg+xml or even application/x-latex it's rather tricky without inspecting the actual data. ...

[Python] Extract content from a file with mime multipart

Hi, I have a file that contain a tiff image and a document xml in a multipart mime document. I would extract the image from this file. How I can get it? I have this code, but it requires an infinite time to extract it, if I have a big file (for example 30Mb), so this is unuseful. f=open("content_file.txt","rb") msg = email.message_fr...

joomla: How to force a php webpage to save as a pdf file

As an example, I have actually been able to generate excel files by changing the content-type for an html document. In this scenario, I would use php to generate the table cells with information gathered from the database and then set the content-type before the page is rendered. Is there a way to do this for pdf's? ...

How can I query IIS for MIME Type Mappings?

How can I programatically read IIS's MIME types? I'd like to use them when I stream data to my clients using WCF. Any tips, or API would be appreciated ...

Firefox "onerror" would not fire even when image is not valid

Hi folks, I have a onerror handler on the image tag to handle switching when the remote image is not found. the problem is that for certain broken remote images, it does not work. http://a3.twimg.com/profile_images/522455109/calvin-and-hobbessm_normal.jpg <img onerror="this.src='/images/pic_not_found.png'" src="http://a3.twimg.com/p...

Can I reliably figure out the correct mime type to serve untrusted content?

Say I let users upload files to my server, and I let users download them. I'd like to set the mime type to something other than just application/octet-stream, so that if the browser can just open them, it does (say, for images, pdf files, plain text files, etc.) Of course, since the files are uploaded by users, I can't trust the file e...

REST - web service response - mime type?

1) Is it important to set the correct mime type for a web service response? 2) what is the correct mime type for a, a) XML response? b) JSON response? application/xml text/xml application/json application/x-javascript text/javascript text/x-javascript text/x-json ...

Displaying an image in php from a file in a directory

I have several images in a directory which is located outside of the public facing portion of the server (outside of the public_html directory). I want to be able to read the image contents with a php file, then output the result to html. For example, I have a php file called getimg.php with the following source code: header('Content-...