Environment
React Native Environment Info:
System:
OS: Linux 4.15 Ubuntu 16.04.4 LTS (Xenial Xerus)
CPU: x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Memory: 520.49 MB / 11.64 GB
Shell: 4.3.48 - /bin/bash
Binaries:
Node: 10.11.0 - ~/.nvm/versions/node/v10.11.0/bin/node
Yarn: 1.10.1 - ~/.nvm/versions/node/v10.11.0/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.11.0/bin/npm
SDKs:
Android SDK:
Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 26.0.3, 27.0.3
API Levels: 23, 25, 26, 27
npmPackages:
react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728
react-native: 0.57.3 => 0.57.3
npmGlobalPackages:
react-native-cli: 2.0.1
Description
I tried to upload a file using axios in react-native using the following sample code
const obj = {
hello: "world"
};
const json = JSON.stringify(obj);
const blob = new Blob([json], {
type: 'application/json'
});
const data = new FormData();
data.append("document", blob);
axios({
url: 'SOME_URL',
method: 'POST',
headers:{...}
},
data: data
})
.then(res => console.log(res))
.catch(res => console.log(res))
On react-native it is setting the content-type as "text/plain" but when I tried on the web it is setting the correct content-type as "multipart/form-data".
I tried setting Content-Type : 'multipart/form-data' but still it reverts back to text/plain in react-native.
Environment
React Native Environment Info:
System:
OS: Linux 4.15 Ubuntu 16.04.4 LTS (Xenial Xerus)
CPU: x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Memory: 520.49 MB / 11.64 GB
Shell: 4.3.48 - /bin/bash
Binaries:
Node: 10.11.0 - ~/.nvm/versions/node/v10.11.0/bin/node
Yarn: 1.10.1 - ~/.nvm/versions/node/v10.11.0/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.11.0/bin/npm
SDKs:
Android SDK:
Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 26.0.3, 27.0.3
API Levels: 23, 25, 26, 27
npmPackages:
react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728
react-native: 0.57.3 => 0.57.3
npmGlobalPackages:
react-native-cli: 2.0.1
Description
I tried to upload a file using axios in react-native using the following sample code
On react-native it is setting the content-type as "text/plain" but when I tried on the web it is setting the correct content-type as "multipart/form-data".
I tried setting Content-Type : 'multipart/form-data' but still it reverts back to text/plain in react-native.