I'm using rn-fetch-blob library to upload some pictures to the server. But I'm getting different types of errors, such as no Boundary on Content-Type or errors with the FormData structure itself such as " of type NSMutableDictionary cannot be converted to NSString", I'm getting quite frustrated.
I got an image array like this:
var images = [
{name 'pic1', data: RNFetchBlob.wrap(imagePathHere), type: 'image/jpeg'},
{name 'pic2', data: RNFetchBlob.wrap(imagePathHere), type: 'image/jpeg'},
{name 'pic3', data: RNFetchBlob.wrap(imagePathHere), type: 'image/jpeg'},
];
Then I create the FormData as follows:
const formData = new FormData();
formData.append('id', userId) // <-- numeric type
formData.append('pictures', images);
I'm doing the post request from RNFetchBlob with 'Content-Type': 'multipart/form-data'
and I pass the formData directly to it.
Any ideas on what's wrong ? I read somewhere that FormData only allows strings or blobs, should I create a Blob from my array? How can I do that?
Thanks in advance.