-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Source code:
fileValidateTypeDetectType: (file, type) => new Promise((resolve, reject) => {
var startOfFile = initObject.mediaType === videoMediaType
? file.slice(0, 12)
: file.slice(0, 4);
var reader = new FileReader();
reader.readAsArrayBuffer(startOfFile);
reader.onload = function () {
switch (initObject.mediaType) {
case imageMediaType:
validateImageFormat(resolve, reject, type, reader.result);
return;
case videoMediaType:
validateVideoFormat(resolve, reject, type, reader.result);
return;
case documentMediaType:
validateDocumentFormat(resolve, reject, type, reader.result);
return;
default:
reject(type);
}
};
})
I process for every uploaded file its signature in order to assure type correctness before any call to backed. The problem appears for all doc/docx files on several windows os' (I tested with win10 and win8 several distributions and as browsers I used chrome/mozilla/edge, the problem persists for all). I debugged a little and I found out that internally file pond perform some type validations on its own (despite the fact that I implemented this function above) and it uses the type autodetected by the browser, which in my case was the empty string. As a result, the file type validation doesn't reject the type from my code but from internal call. What should I do in order to be able to upload doc/docx? I read in a previous topic that someone mentioned that office package may be needed in order to help browser correctly detect file types but this is not an option.