I am trying to upload a Blob using my react native app but unable to do so.
Below code is not working in react native but working fine in web browser:-
const formdata = new FormData();
const content = '<a id="a"><b id="b">hey!</b></a>';
const blob = new Blob([content], { type: "text/xml" });
formdata.append("file", blob);
const requestOptions = {
method: "POST",
body: formdata,
redirect: "follow",
};
fetch("https://some-upload-api-path", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
What’s the difference in uploading files in react native and web browsers.