I try upload image on server with this code:
updateAvatar(token, photo) {
return postImage(
"http://lk.skilla.ru/myapi/updateAvatar",
[
{
name: "avatar",
filename: "avatar.jpg",
type: "image/jpg",
data: Platform.OS === "android" ? RNFetchBlob.wrap(photo) : photo,
},
],
token
);
},
const postImage = (url, params, token) => {
return RNFetchBlob.config({ fileCache: true, appendExt: "jpg" })
.fetch(
"POST",
url,
{ Authorization: token, "Content-Type": "multipart/form-data" },
params
)
.then((res) => {
console.log("response");
console.log(res.text());
return Platform.OS === 'android' ? 'file://' + res.path() : '' + res.path()
})
.catch((error) => console.log(error));
};
And on android all work fine, but on iOS file returned by RN-Fetch-Blob does not exist. How to wrap url on iOS? RNFetchBlob.wrap don't work
This is how I got it to work for me.