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

File type validation behaves differently when dropping a folder #36

Open
alex7654 opened this issue Oct 11, 2020 · 6 comments
Open

File type validation behaves differently when dropping a folder #36

alex7654 opened this issue Oct 11, 2020 · 6 comments

Comments

@alex7654
Copy link

alex7654 commented Oct 11, 2020

I set up file type validation with the folloing accepted types:

acceptedFileTypes: [
'image/',
'audio/
',
'video/',
'text/
',
'application/pdf',
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'application/x-zip-compressed',
],

When dropping files directly (not dropping a folder) it works perfectly (see attached image validateType_directly.png).
When dropping a folder containing the exactly same files as before, some (but not all) files types are blocked (see attached image validateType_folder.png), although they should be accepted.

So it seems, files are processed differently when a folder ist dropped.

Any advice is highly appreciated.

PS:
After deactivation of FilePondPluginFileValidateType, upload works correctly, no matter if the files are contained in a folder or not (of course all files are accepted in this case).

validateType_directly
validateType_folder

@rikschennink
Copy link
Collaborator

You can can try to see how the browser interprets the files using the fileValidateTypeDetectType hook, maybe there's a difference and you can use the hook to correct the browser interpretation.
https://pqina.nl/filepond/docs/patterns/plugins/file-validate-type/#custom-type-detection

@alex7654
Copy link
Author

alex7654 commented Oct 15, 2020

Thanks for your response. I used fileValidateTypeDetectType to determine the types of the files added.
When adding one image and one DOCX-Document directly, the files are recognized as "object file" and the types are shown correctly (see first image below).

But when adding the same files by adding the containing directory, the files are recognized as "object blob" and the type of the DOCX-blob is empty, whereas the file type of the image-blob ist still shown correctly (see second image below).
Is there a (simple) way to obtain the types of the blobs not recognized?

directly
directory

@rikschennink
Copy link
Collaborator

I'll see if I have some time to investigate this next week.

@alex7654
Copy link
Author

Thanks in advance!

@rikschennink
Copy link
Collaborator

@alex7654 Just checked. The browser doesn't recognise the file type when read from a folder vs when a file is dropped on its own (don't know why).

When dropping a folder FilePond tries to guesstimate the file extension and creates a Blob instead of a File because it can't create File objects on IE11. I'm pushing a fix (4.23.1) where it doesn't create a Blob if the type cannot be guesstimated. But still that means the type is empty and you will have to correct for it in the fileValidateTypeDetectType method. I'd advise to do so by checking the extension and mapping it to one of the mime types in the accepted file types list.

@rikschennink rikschennink removed the bug label Nov 2, 2020
@alex7654
Copy link
Author

alex7654 commented Nov 2, 2020

Thank you for the update!

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