Uploading large videos to Cloudinary in Chunks

I have an app that allows users to upload their videos.
We need users to be able to upload long videos, that are often over 100mg in size.

I’m struggling to upload those videos to Cloudinary.
I’m using Expo Go, React Native.

I’ve tried implementing chunks, but I can’t even get axios / fetch to upload a full video using blob. It seems it can’t recognize the blob.

 const handleSendChunkedVideo = async (uri) => {

    const response = await fetch(uri);
    const blob = await response.blob();

    console.log('uri', uri);

    await send(blob);
}


const send = async (piece) => {
    const YOUR_CLOUD_NAME = "";
    const YOUR_UNSIGNED_UPLOAD_PRESET = "";

    const POST_URL =
        "https://api.cloudinary.com/v1_1/" + YOUR_CLOUD_NAME + "/auto/upload";

    const formdata = new FormData();

    formdata.append("file", piece);
    formdata.append("cloud_name", YOUR_CLOUD_NAME);
    formdata.append("upload_preset", YOUR_UNSIGNED_UPLOAD_PRESET);

    try {

        await fetch(POST_URL, {
            method: 'post',
            body: formdata,
            headers: {
                'Content-Type': 'multipart/form-data',
                'X-Requested-With': 'XMLHttpRequest',
            }

        })
            .then(res => res.json())
            .then(data => {
                console.log('Upload Result', data);
            })
            .catch(err => {
                console.log('err', err);
                uploadResult = 'failed'
            });
}
    catch (error) {
        console.log("error", error);
    }

This is the error I get:

Upload Result Object {
  "error": Object {
    "message": "Missing required parameter - file",
  },
}

How do I get expo to be able to at least upload a blob, and not Base64, so that then I can work on the chunking part?
rn-fetch-blob doesn’t work with my expo app, so I can’t use it.

Thanks!


Android and iOS


expo-env-info 1.0.5 environment info:
System:
OS: macOS 12.0.1
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.14.0 - /usr/local/bin/node
Yarn: 1.22.18 - /opt/homebrew/bin/yarn
npm: 8.5.5 - /usr/local/bin/npm
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
IDEs:
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
npmPackages:
@expo/metro-config: ^0.3.17 => 0.3.17
expo: ^45.0.0 => 45.0.4
react: 17.0.2 => 17.0.2
react-dom: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-web: 0.17.7 => 0.17.7
npmGlobalPackages:
eas-cli: 0.52.0
expo-cli: 6.0.1
Expo Workflow: managed

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.