Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Content-Type on uploading file using axios in react-native #21814

Closed
vineethgeorge03 opened this issue Oct 16, 2018 · 2 comments
Closed
Labels
Bug Platform: iOS iOS applications. Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot. Type: Invalid This issue does not belong here. Applying this label will cause issue to be closed.

Comments

@vineethgeorge03
Copy link

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.

@react-native-bot react-native-bot added Platform: iOS iOS applications. Platform: Linux Building on Linux. labels Oct 16, 2018
@stale
Copy link

stale bot commented Jan 16, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 16, 2019
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 26, 2019
@hramos hramos removed the Bug Report label Feb 6, 2019
@Salakar Salakar added the Type: Invalid This issue does not belong here. Applying this label will cause issue to be closed. label Mar 19, 2019
@Salakar
Copy link
Contributor

Salakar commented Mar 19, 2019

Hey @vineethgeorge03, thanks for filling out this issue - given that this is for Axios please could you raise this issue on Axios.

@Salakar Salakar closed this as completed Mar 19, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Mar 19, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: iOS iOS applications. Platform: Linux Building on Linux. Resolution: Locked This issue was locked by the bot. Type: Invalid This issue does not belong here. Applying this label will cause issue to be closed.
Projects
None yet
Development

No branches or pull requests

4 participants