filestack / filestack-js

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

Mobile browser upload issue #446

Open thenderson55 opened 3 years ago

thenderson55 commented 3 years ago

Sometimes when I try uploading from my Samsung Android (version 10) phone using Chrome browser, it fails.

These are my pickOptions:

const pickOptions = (
  func: (img: string) => Promise<void> | void,
  setPicIsLoading:
    | React.Dispatch<React.SetStateAction<boolean>>
    | ((loading: boolean) => void) = () => {},
  setError: (message: string) => void = () => {}
) => {
  return {
    onFileSelected: (file: any) => {
      if (file.size > 4032 * 3024) {
        throw new Error(
          "ファイルが大きすぎます。1MB以下のものを選択してください。"
        );
      }
    },
    fromSources: ["local_file_system"],
    customText: photoPickerText,
    accept: ["image/*" /*"application/*"*/],
    transformations: {
      crop: {
        aspectRatio: 1,
      },
      rotate: true,
    },
    uploadInBackground: false,
    onUploadDone: async (res: { filesUploaded: { url: string }[] }) => {
      try {
        await func(res.filesUploaded[0].url);
      } catch (err) {
        setError(err.response.message || err.message || err);
      }
    },
    onCancel: () => {
      setPicIsLoading(false);
    },
    onFileUploadFailed: (err: any) => {
      console.log("FS ERROR", err);
      setError(err.response.message || err.message || err);
      setPicIsLoading(false);
    },
  };
};

Seems to throw this error:

Error: FS-Cannot upload file. Start request failed
    at new e (filestack.esm.js:41)
    at filestack.esm.js:41
Screenshot 2021-06-29 at 11 21 38

Sentry also throws it:

Screenshot 2021-06-29 at 11 22 40
amitrahav commented 1 year ago

Having same issue on my end