filestack / filestack-js

Official Javascript SDK for the Filestack API and content ingestion system.
https://www.filestack.com
MIT License
206 stars 77 forks source link

v3.21.1 breaks `accept` picker option for .zip files #413

Open lmcnearney opened 3 years ago

lmcnearney commented 3 years ago

The latest release of the picker component (which doesn't appear to be a part of this repository) breaks handling of .zip files when used in the accept option. Rolling back to the prior release (v3.21.0) resolves the issue.

Reproducing the issue is simple - just pass .zip as an accept option to the picker and then try to upload a zip file. You will receive this validation error message (all client side):

zip

khoa88 commented 3 years ago

The .mp3 extension for accept option also has the same error when recording the audio.

pcholuj commented 3 years ago

Hi, we are currently working on problems with accept option in picker

lukejpreston commented 3 years ago

I don't know if this is related. When I set accept to the following

[
  ".pdf",
  ".ppt",
  ".doc",
  ".odt",
  ".odp",
  ".docx",
  ".rtf",
  ".xls",
  ".xlsx",
  "image/*",
  "video/*",
  "audio/*",
  "text/plain",
  "text/csv"
]

I am still able to upload zip files

pcholuj commented 3 years ago

@lukejpreston can you provide more info about how you are trying to upload files ? Browser, system and how are you uploading those files?

I use example https://jsfiddle.net/pcholuj/2ezrc70b/ and im unable to add zip file

lukejpreston commented 3 years ago

Thanks for the quick reply @pcholuj After seeing your jsfiddle I realised we were using an old version of the library. The latest version works fine (from v1 -> v3)

ericm546 commented 3 years ago

I was opening a new bug, but I think this it's related to this bug:

Starting with Filestack-js 3.21.1, I have the following error when uploading an AVI file in a Filestack where the parameter accept is set to ["avi"].

"File drop.avi is not an accepted file type. The accepted file types are .avi"

The error only occur in Chrome. It works in Safari and Firefox. It also works if I rollback to the NPM version 3.21.0.

The error occur in the cdn file "/1.20.1/picker.js". It looks like it's trying to see if the file MimeType is part of "getters.acceptMime".

That MimeType value is "video/avi" in Chrome and "video/x-msvideo" in Safari.

It works in Chrome in the cdn 1.20.0 version because the following code (removed in 1.20.1) prevent the ERROR_FILE_NOT_ACCEPTABLE from being displayed.

if (!e.getters.customText)
    return !0;
sshaw commented 3 years ago

To fix this problem we rolled back to 3.15.0 and used extensions. So far so good.

pcholuj commented 3 years ago

The main problem with this is that firefox and chrome returns different mimetypes for avi files. There is much more problems with it so we decided to add posibility to provide your own acceptFn callback: https://jsfiddle.net/pcholuj/42pLfv0o/1/