joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

Uploading empty files when the content type is 'multipart/form-data' #651

Closed apgsn closed 3 years ago

apgsn commented 3 years ago

Hi, I am using your library to upload base64 images. My setup follows the multipart/form-data example from the docs:

const imageData = 'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFklEQVR42mNk+H/iPwMRgHFUIX0VAgAmtxvHR58D2wAAAABJRU5ErkJggg=='

RNFetchBlob.fetch(
  'POST',
  'http://localhost:12345/api/upload',
  {
    'Content-Type': 'multipart/form-data',
    'Authorization': 'Bearer ...',
  },
  [{
    name: 'file',
    filename: 'file.jpeg',
    type: 'image/jpeg',
    data: imageData,
  }],
);

The problem is that when I look at the files section of the request received by my Flask server, I get a file object with all the information provided in the body (name, type, etc.), but no content.

I tried uploading using 'Content-Type': 'octet-stream' and the data is properly loaded as binary, but I really need to send it to the server as multipart content.

Versions

apgsn commented 3 years ago

Nevermind, it was an issue with the backend.