jeudi 7 janvier 2016

@content_type in paperclip gem returns different value

In windows, I get:

@content_type="application/octet-stream"

Full trace:

"attachments_attributes"=>{"0"=>{"attachment"=>#<ActionDispatch::Http::UploadedFile:0x007f7bb52becc8 @original_filename="ms_document.doc", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"post[attachments_attributes][0][attachment]\"; filename=\"doc\"\r\nContent-Type: application/octet-stream\r\n", @tempfile=#<Tempfile:/tmp/RackMultipart20160108-8859-x51qhj>>}}}

In Linux I get:

@content_type="application/msword"

Full trace:

"attachments_attributes"=>{"0"=>{"attachment"=>#<ActionDispatch::Http::UploadedFile:0x007f7bb5d585d0 @original_filename="ms_document.doc", @content_type="application/msword", @headers="Content-Disposition: form-data; name=\"post[attachments_attributes][0][attachment]\"; filename=\"doc.doc\"\r\nContent-Type: application/msword\r\n", @tempfile=#<Tempfile:/tmp/RackMultipart20160108-8859-9m1xgv>>}}}

The question is, why I received different @content_type while I'm uploading the same file but only different OS.

I'm using:

  1. rails 3
  2. paperclip '4.3.2'

Aucun commentaire:

Enregistrer un commentaire