PDF File upload : wrong mime type (js)

RESOLVED FIXED in mozilla25

Status

Core Graveyard
File Handling
RESOLVED FIXED
4 years ago
a year ago

People

(Reporter: dr_fx59, Assigned: poiru)

Tracking

22 Branch
mozilla25
x86_64
Windows 7

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [mentor=jdm][lang=c++][good first bug])

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0 (Beta/Release)
Build ID: 20130618035212

Steps to reproduce:

I am using an input of type file to upload pdf using ajax on Firefox 22.0


Actual results:

I want to check the file mime type to be sure to get a pdf.
So I am using this javascript : 
var file = uploader.container.find('input[type="file"]')[0].files[0];

then I check the property  'type' of the file var. (file.type)

The value is 'application/octet-stream' instead of 'application/pdf' !



Expected results:

The value of file.type should be  'application/pdf'.

The same code with the same file works on IE10 and Chrome 28.0.1500.71.
Yury, any suggestions please ?
Component: Untriaged → File Handling
Product: Firefox → Core

Comment 2

4 years ago
I think we've got two choices here: if the OS does not appear to be providing us with any good hint, we can add the pdf extension to the list extraMimeEntries list in nsExternalHelperAppService, or we could rely on pdf.js to add a MIME entry for PDFs via the ext-to-type-mapping category. Personally, I think we would want this regardless of the presence of pdf.js.

Comment 3

4 years ago
Boris, you seem to have reviewed changes to the extraMimeEntries list in the past. Would adding one for PDF make sense here?
Flags: needinfo?(bzbarsky)

Comment 4

4 years ago
I think adding PDF there is totally reasonable.
Flags: needinfo?(bzbarsky)

Comment 5

4 years ago
This will be a very simple change for someone to make.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [mentor=jdm][lang=c++][good first bug]
(Assignee)

Comment 6

4 years ago
Created attachment 777192 [details] [diff] [review]
Add default MIME type definition for .pdf as 'application/pdf'
Assignee: nobody → birunthan
Status: NEW → ASSIGNED
Attachment #777192 - Flags: review?(josh)

Updated

4 years ago
Attachment #777192 - Flags: review?(josh) → review+

Updated

4 years ago
Keywords: checkin-needed

Comment 7

4 years ago
Thanks!
https://hg.mozilla.org/integration/mozilla-inbound/rev/02acc75e4e0c
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/02acc75e4e0c
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
(Reporter)

Comment 10

4 years ago
Thanks !
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.