0

Good day, I have been trying to upload a video taken from camera with ImagePicker to the server, but so far it's failed, i've tried some codes from similar issues here to no avail.

I would love to get help on this issue. Thanks

My Codes Formdata

let data = new FormData();
    data.append(this.state.type, {
        name: 'videofile.mp4',
        uri: (this.state.video.uri),
        type: 'video/mp4'
    });

Request

let headers = {
  Accept: "application/json",
  "Content-Type": "multipart/form-data",
  "Access-Control-Allow-Origin": "*",
  "Accept-Encoding": "gzip, deflate, br"
}

if (context != undefined) {
  headers['Authorization'] = 'Bearer ' + context.state.token;
}

return fetch(Base + Url, {
  method: "POST",
  headers: headers,
  body: (!PreparedData) ? PrepareData(Data) : Data
})
  .then(response => {

    return response.json();
  })
  .then(data => {

    return PrepareResult(data, '');
  })
  .catch(error => {

    return PrepareResult({}, error, true);
  });
  • Hi, I'm also running into the same issue. Did you get any resolution for this? – Sankar Jun 30 '20 at 20:20
  • Hi, I would like to know if you images are uploading fine, also have you created the file object? in my case for the video upload, turned out that i couldn't access the file in the DCIM directory on android, so after taking my video, i move it out to another folder using react-native-fs then use rn-fetch-blob to make the upload. – Godfrey Odenigbo Jun 30 '20 at 23:37

0 Answers0