wkh237 / react-native-fetch-blob

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

curl -F equivalent with RNFetchBlob #655

Open dahudson88 opened 6 years ago

dahudson88 commented 6 years ago

I am having some issues translating ‘-F’ in curl to something in react-native-fetch-blob when doing an upload. The API does not call for additional headers as shown in the example but rather a file and information about that file. Is there a way to translate this curl command into something that RNFetchBlob can process?

Curl Command:

curl -X POST https://something./api/uploadFile/ 
  -F file[]=@newfile.jpg \
  -F name[]=tester \

RNFetchBlob Command:

RNFetchBlob.fetch('POST',https://something./api/uploadFile/, {
        Authorization : 'Basic 1234567NO',
        'Content-Type' : 'application/octet-stream'
      },imageData).then((resp) => {
     }).catch((err) => {}

React-Native version: 0.50.3 RNFetchBlob version:0.10.8

jrodriguesimg commented 6 years ago

I can't figure this out either. I'm trying upload picture to strapi from ios. Used a bunch of ways but none of them worked. However with curl works.