Skip to content

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

@JohnPaul97

Description

@JohnPaul97

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions