Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filepond type validation doesn't work for doc and docx files on several windows platforms #34

Open
JohnPaul97 opened this issue Sep 8, 2020 · 1 comment

Comments

@JohnPaul97
Copy link

JohnPaul97 commented Sep 8, 2020

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.

@rikschennink
Copy link
Collaborator

setting acceptedFileTypes to for example doc/docx and then returning doc/docx from the fileValidateTypeDetectType should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants