function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How do I change the MIME type of a static resource?

I have a static resource that contains a style sheet. It's defined with <style type="text/css"> at the top.

When I upload the file for this resource, Salesforce creates it with a MIME type of text/plain. It doesn't pick up the MIME type from the file's contents. It doesn't let me specify the MIME type when I upload the file. There doesn't seem to be a way to change the MIME type of an existing static resource.

This is a problem because Firefox doesn't want to load a style sheet whose MIME type isn't text/css.

How can I define or change the MIME type of a static resource?



PS. If there was a better place to post this message, please let me know. Thanks!

Right after posting this question, it occurred to me that using the Eclipse IDE, I can change the MIME type in the static resource's meta XML file. The contentType was set to text/plain, and when I changed it to text/css and used the Eclipse IDE to save the file to the server, Setup / Develop / Static Resources showed the MIME type to be text/css.

Still, it seems like there ought to be a way to change the MIME type through the browser, rather than having to resort to the IDE. Is there?


Really? Over 8 years later and this is all we have on this issue? I have a similar problem with zip files. On a mac they upload fine as application/zip but on my pc they upload as application/x-zip-compressed. Seems so cumbersome to do this through Eclipse. Thanks for your tip Jeri.
Lucian CiufudeanLucian Ciufudean
Same problem here when uploading leaflet, the css file is uploaded as "text/html"
David BucherDavid Bucher

Easiest way I've found to do it is with the developer console.
Open the developer console, click "Query Editor" at the bottom, then query:

SELECT Id, Name, ContentType FROM StaticResource

You can optionally add "WHERE Name = 'Your File Name'" if you're sure of the file. Check the "Use tooling API" box and click Execute. In the results that come up, double click the ContentType of the resource you want to change, type in your new value, then click Save Rows.

Enjoy your new mime type.

@David Bucher, suggested way is the best way to update instead of using IDE 
先通 楊先通 楊
@David Bucher, thank you for your post. It saved me.
harisripadmini vharisripadmini v
Hi all,

I'm using jquery datatable plugin in lightning component and struck with the following error:
 "Refused to apply style from '' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled."
I tried to edit the ContentType through dev console as mentioned above, and still facing the same issue. 
Are there any compatibility version differences regarding jquery datatable plugin for lightning components, please help in solving this issue.

Thanks in Advance!!