Uploading video recorded with Expo Camera to server

1.2k Views Asked by At

I am recording video using expo camera, the recorded video is saved in the cache and I want to upload the recorded video to the server. I have the uri to the video, but to upload it to the server I need the file itself. How can I add the file to the body of the request? (I can't use rn-fletch-blob or react-native-fs, because it 's an expo project)

1

There are 1 best solutions below

1
On BEST ANSWER

Ok so you have the uri

Now we have to create a form-data as it is a file.

to create form-data follow these steps

Create A function

const CreateFormData = (uri) => {
  // Here uri means the url of the video you captured
  const form = new FormData();
  form.append("File", {
    name: "SampleVideo.mp4",
    uri: uri,
    type: "video/mp4",
  });

  // Now perform a post request here by adding this form in the body part of the request
  // Then you can handle the file you sent in the backend i.e server
};