Defect #19435
closedPDF's are being uploaded with wrong mimetype "application/force-download" instead of "application/pdf"
0%
Description
Starting with Redmine 3.0 all PDF attachments beeing uploaded are stored in the database with the wrong mimetype "application/force-download" instead of "application/pdf".
This is my redmine3 dev installation which I run on a mac:
Environment: Redmine version 3.0.1.stable Ruby version 2.0.0-p481 (2014-05-08) [universal.x86_64-darwin14] Rails version 4.2.1 Environment production Database adapter Mysql2 SCM: Subversion 1.7.19 Cvs 1.12.13 Git 1.9.5 Filesystem Redmine plugins: redmine_lightbox2 0.2.2
This happens for drag&drop uploads as well as for "normal" file uploads to tickets.
It seems as if this also results in the following webrick warning when trying to download a PDF attachment:
[2015-03-20 19:37:04] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
This warning also appears for images when beeing downloaded.
Files
Updated by Jean-Philippe Lang over 9 years ago
- Status changed from New to Needs feedback
- Priority changed from Urgent to Normal
- Resolution set to Cant reproduce
This seems to be a browser issue. Redmine just stores the content type that is sent by the browser. What is yours? Can you check the headers of the request that is sent when uploading files?
I have just tested with 3.0.1 and Firefox 36, PDF uploaded by selection or drag'n drop are stored with application/pdf content type.
Updated by Tobias Fischer over 9 years ago
this is part of the redmine 3.0.1 log for a PDF upload in Firefox 36.0.1 on mac yosemite 10.10.2:
2015-03-21 12:38:10 +0100 Processing by AttachmentsController#upload as JS Parameters: {"attachment_id"=>"1", "filename"=>"test.pdf", "content_type"=>"application/force-download"} Current user: admin (id=1) Saving attachment '/Users/tobiasfischer/Entwicklung/redmine3/files/2015/03/150321123810_test.pdf' (74340 bytes)
This is the firebug network report for a similar drag&drop upload:
Parameter:
Request-Header:
POST /uploads.js?attachment_id=1&filename=test.pdf&content_type=application%2Fforce-download HTTP/1.1 Host: 0.0.0.0:3003 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:36.0) Gecko/20100101 Firefox/36.0 Accept: application/js Accept-Language: de,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate X-CSRF-Token: +6LU1Y5BMOuMe/kWfMLoeUla7zHGO/F6S9dppPyQYX54SEHlDuIZ8XX8uyKICaat8DnYWtv3DOie9Uv+VLEhxw== Content-Type: application/octet-stream X-Requested-With: XMLHttpRequest Referer: http://0.0.0.0:3003/issues/4 Content-Length: 74340 Cookie: _redmine_session=RC9lVkNSVm5FeTF3a........4b31dfae9900a3dd59b Connection: keep-alive Pragma: no-cache Cache-Control: no-cache
Answer:
HTTP/1.1 200 OK X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block X-Content-Type-Options: nosniff Content-Type: text/javascript; charset=utf-8 Etag: W/"f6a322439f4d25ab25f9c32bc6628cb4" Cache-Control: max-age=0, private, must-revalidate X-Request-Id: 207bdc30-be34-4340-9756-df734d33e698 X-Runtime: 0.013329 Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-05-08) Date: Sat, 21 Mar 2015 11:42:00 GMT Content-Length: 328 Connection: Keep-Alive Set-Cookie: _redmine_session=SzR3czBUL0cyTkx3a......6368866227ad22c317; path=/; HttpOnly
This is weird as it works for you in Firefox36 and not for me.
Although, for redmine 2.6.3 it works well with Firefox36 - but the query string doesn't contain the content_type parameter anyway.
And finally, it seems to work well in Chrome 41:
Processing by AttachmentsController#upload as JS Parameters: {"attachment_id"=>"1", "filename"=>"test.pdf", "content_type"=>"application/pdf"} Current user: admin (id=1) Saving attachment '/Users/tobiasfischer/Entwicklung/redmine3/files/2015/03/150321125540_test.pdf' (74340 bytes) Rendered attachments/upload.js.erb (0.6ms) Completed 200 OK in 39ms (Views: 1.6ms | ActiveRecord: 16.3ms)
Updated by Tobias Fischer over 9 years ago
Disabling all firefox addons doesn't help. Still the same issues.
Updated by Tobias Fischer over 9 years ago
Alright, this seems to be a Firefox "bug" (at least I'll refer to it as a bug, the developers don't) discussed in https://bugzilla.mozilla.org/show_bug.cgi?id=373621
Note 45 seems to give an explanation why this is happening and Comment 59 summarizes the thread with the suggestion to delete the file mimeTypes.rdf in your Firefox profile folder.
This helped and I'm no longer experiencing the issues in Redmine after deleting the file and a Firefox restart.
You can close the issue. Sorry for the trouble.
Cheers,
Tobias
Updated by Tobias Fischer over 9 years ago
[2015-03-20 19:37:04] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Regarding the Webrick warning I opened a new issue: #19438
Updated by Go MAEDA over 9 years ago
- Status changed from Needs feedback to Closed
Thanks for feedback.
It is a browser issue, I close this.