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

tus-js-client doesn't upload file larger than 100Mb for Android #508

Open
Xotonori opened this issue Nov 21, 2022 · 5 comments
Open

tus-js-client doesn't upload file larger than 100Mb for Android #508

Xotonori opened this issue Nov 21, 2022 · 5 comments
Labels
bug react-native Issues with tus-js-client in React Native

Comments

@Xotonori
Copy link

Xotonori commented Nov 21, 2022

tus-js-client doesn't upload file larger than 100Mb for Android. I've got next error - "Failed to upload because: Error: tus: cannot fetch file.uri as Blob, make sure the uri is correct and accessible. [object Object]"

I get video file data by "react-native-document-picker" library.

Than i get data like:

const assets = [{
"fileCopyUri": "file:///data/user/0/...projectName...development/files/9467e842-4db4-4bf7-849d-f3c400120665/fileName.mp4", 
"name": "basketball2k168MB.mp4", 
"size": 155686888, 
"type": "video/mp4", 
"uri":"content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2FfileName.mp4"
}];

Than i push assets to tus upload component and get presight params:

const uploadFile = (file: any, idx: number) => {
  const fileSize = file?.size || 0;

  dispatch(GameVimeoPresignUrl(idx, fileSize)).then(
    (data: VimeoPresignUrl) => {

      const {uploadLink, chunkSize, uri} = data;
      
      const uploader = new tus.Upload(file, {
        uploadUrl: uploadLink,
        endpoint: uploadLink,
        retryDelays: [0, 3000, 5000, 10000, 20000],
        chunkSize,
        metadata: {
          filename: `video.${file.name}`,
          filetype: file.type,
        },

        onError: onUploadError,
        onProgress: (bytesUploaded, bytesTotal) => {
          const percent = bytesUploaded / bytesTotal;
          onProgress(percent, idx);
        },
        onSuccess: () => {
          console.log('Successfully uploaded to:', uri);
          onUploadSuccess(uri);
        },
      });
      uploader.start();
    },
  );
};

And when uploading started, I get this error - "Failed to upload because: Error: tus: cannot fetch file.uri as Blob, make sure the uri is correct and accessible. [object Object]"

Files lower than 100Mb uploading very well, but larger don't( This problem only for an Android, IOS is ok.

@Xotonori Xotonori added the bug label Nov 21, 2022
@Valere3162
Copy link

Did you found any solution for this? I am also facing the exact same issue.

@Xotonori
Copy link
Author

Xotonori commented Feb 6, 2023

Unfortunatly no =(

@nh2
Copy link
Contributor

nh2 commented Mar 24, 2023

I cannot confirm this issue.
I can successfully upload a 500 MB video file with tus-js-client 3.0.1 to my own TUS server implementation, with both Firefox and Chrome on Android 11 (LineageOS on a Google Pixel 1).


Separate: In your code:

      const uploader = new tus.Upload(file, {
//...
        chunkSize,

It looks like here you're passing the large file's full size as chunkSize.

According to chunkSize docs this will pull the whole file into RAM:

A large chunk size (more than a GB) is problematic when a reader/readable stream is used as the input file. In these cases, tus-js-client will create an in-memory buffer with the size of chunkSize

On Android devices you usually don't have a lot of RAM, so this might be problematic.

@H4mxa
Copy link

H4mxa commented Oct 3, 2023

When attempting to upload a large file on iOS, the app's memory usage rapidly increases to 2GB and subsequently causes the app to crash.

@Acconut
Copy link
Member

Acconut commented Oct 17, 2023

@H4mxa Are you using React Native on iOS? Or are you using it in the browser? Because the original question was using React Native.

@Acconut Acconut added the react-native Issues with tus-js-client in React Native label Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug react-native Issues with tus-js-client in React Native
Projects
None yet
Development

No branches or pull requests

5 participants