Wrong mime-type when uploading pdf

From FVue
Jump to: navigation, search

Problem

When uploading a pdf within a Ruby on Rails application, I receive this error message about a wrong mime-type:

is not one of application/pdf, application/x-pdf

The expected mime-types are set like this:

validates_attachment_content_type :pdf, :content_type => ['application/pdf','application/x-pdf']

Solution

It appears to be caused by my Firefox-setting { Edit | Preferences | pdf }. There appeared to be four wrong entries associated with PDF-files:

  • application/force-download
  • application/x-zip
  • application/x-zip-compressed
  • application/zip

I deleted these entries from my ~/.mozilla/firefox/xxx/mimeTypes.rdf file:

<RDF:Description RDF:about="urn:mimetype:application/force-download"
                 NC:description="PDF document"
                 NC:value="application/force-download"
                 NC:editable="true">
  <NC:fileExtensions>pdf</NC:fileExtensions>
  <NC:fileExtensions>zip</NC:fileExtensions>
  <NC:handlerProp RDF:resource="urn:mimetype:handler:application/force-download"/>
</RDF:Description>
<RDF:Description RDF:about="urn:mimetype:application/x-zip"
                 NC:value="application/x-zip"
                 NC:editable="true"
                 NC:description="PDF document">
  <NC:fileExtensions>zip</NC:fileExtensions>
  <NC:fileExtensions>pdf</NC:fileExtensions>
  <NC:handlerProp RDF:resource="urn:mimetype:handler:application/x-zip"/>
</RDF:Description>
<RDF:Description RDF:about="urn:mimetype:application/x-zip-compressed"
                 NC:value="application/x-zip-compressed"
                 NC:editable="true"
                 NC:description="PDF document">
  <NC:fileExtensions>zip</NC:fileExtensions>
  <NC:fileExtensions>pdf</NC:fileExtensions>
  <NC:handlerProp RDF:resource="urn:mimetype:handler:application/x-zip-compressed"/>
</RDF:Description>
<RDF:Description RDF:about="urn:mimetype:application/zip"
                 NC:description="PDF document"
                 NC:value="application/zip"
                 NC:editable="true">
  <NC:fileExtensions>pdf</NC:fileExtensions>
  <NC:fileExtensions>zip</NC:fileExtensions>
  <NC:handlerProp RDF:resource="urn:mimetype:handler:application/zip"/>
</RDF:Description>

and restarted Firefox. Now uploading a PDF works all-right.

Comments

blog comments powered by Disqus