-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
Network Error when send file with formData(axios or fetch) on Android. Works fine on IOS. #44657
Comments
|
This issue still in const formData = new FormData()
This returns network error REACT-NATIVE-INFO output:- System: |
Same issue here.. const fileExtension = coverImage.split(".").pop();
When I console.log req.file and req.body, undefined [Object: null prototype] { Here I'm not sending any data in req.body only sending file to req.file which I get undefined.. |
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days. |
Same problem here yet |
@saadkhan2211 @felipeavila-vp @H3tansh Hi, could you provide Missing Reproducible Example as above, so I can help you solve this problem? |
@huzhanbo1996 below is my working code, It only works if I use deployed HTTPS API URL , but do not work if I use HTTP endpoint running on my localhost.
P.S:- Issue only persist in android. here is the issue I've created |
Same here, but with windows.
|
Hi Everyone, Mine got fixed after some troubleshooting...All I did was that I removed Content-Type part from headers and It worked |
I had the same problem after upgrade React Native to 0.72.17. And in my case renamed from Content-Type => content-Type fixed the error. |
same issue, |
Same issue. |
Same issue |
Same issue, its only happening in android, iOS is fine. |
i have same issue |
not work for me =( |
not work here =( |
In my case it was the timeout. I defined the timeout to 3000 and takes more than that to upload file. So I just increased the timeout or even can remove if you don't need to control the timeout. |
The problem is buried down into const part = {
headers: [ ['content-type', 'image/png'] ],
uri: 'file:///...',
name: fileName,
mimeType: 'image/png'
} If there is no Content-type header, even though Even better - if you explicitly specify I was able to workaround the problem by registering custom |
@simeon-kirov Hi, I think I have encountered the same problem as you. When I use HTTPS to send formData, it always returns 403, and the request does not reach Nginx. Can you share your solution steps? |
Hi @bestchenyan, You can find example workaround implementation here: https://github.com/simeon-kirov/expo-debug/tree/main. However, you're saying in your case it always returns HTTP error 403. This is different from what I observe. In my case I'm getting just "Network error" message without any HTTP code. Probably your problem is related to self-signed/untrusted SSL certificates on the server. Make sure that you've registerd your server certificates as trusted. Check this documentation: https://developer.android.com/privacy-and-security/security-config. Also, you can see the configuration in my project:
|
Same issue |
I managed to fix it on Android by just setting axios.post('http://your-server.com/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
}) |
Having the same problem, only on Android as well. Using Axios worked |
@zwenza Could you share your code? |
Here not work using axios or fetch. =( |
Hello friend! |
async function handleSubmit() {
} This is my code; sometimes it works, and sometimes it doesn't. Can someone please help? |
same issue. Please advice if there is any other ways to POST or PUT form data or file properly with current react native version |
same issue, any found solution? |
same issue in android |
I am working on two projects both are in react native in one project formData works perfectly in other gives error after few successful transfer, I am unable to understand why this behaviour |
Description
When I try to send some post request sending a file with formData I receive a Network Error. Most of the time the request works fine, but sometimes I receive this error. The problem occurs when use Android, works fine with IOS.
Recently I updated my application to react-native 0.74.1(latest), before the version was 0.64.4. In older version all works fine.
Current versions:
Steps to reproduce
Only try to submit some files using formData
React Native Version
0.74.1
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: