react-native-fetch-blob icon indicating copy to clipboard operation
react-native-fetch-blob copied to clipboard

JSON with multipart/form-data (upload image along with json payload)

Open Noitidart opened this issue 6 years ago • 2 comments

I am trying to upload multipart/form-data but with JSON. I am trying this:

RNFetchBlob.fetch(
        'PUT',
        `${fetchApi.DOMAIN}/api/user`,
        {
            Accept: 'application/json',
            Authorization: `Bearer ${fetchApi.TOKEN}`,
            'Content-Type': 'multipart/form-data'
        },
        [
              { name:'avatar', filename:fileName, type:mimeType, data:RNFetchBlob.wrap(filePath) },
              { data: JSON.stringify(payload} }
        ]
    )

Please notice the { data: JSON.stringify(payload} }, I omitted the name key. My backend is seeing this as empty. May you please advise?

Noitidart avatar Jan 15 '18 04:01 Noitidart

@Noitidart do you see that on android?

kanekv avatar May 26 '18 05:05 kanekv

@Kane-Sendgrid yes on android.

Noitidart avatar May 26 '18 08:05 Noitidart