Upload file "Network request failed" with FormData in 0.85.0
未关闭
还没有人认领这个 Issue。
Resolution: PR Submitted
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
Hello, I currently do this in version 0.85.0 and I get the error Network request failed.
The image are
{
name: 'IMG-20251203-WA0008.jpg',
type: 'image/jpeg',
uri: 'content://...' or 'file://...
}
const formData = new FormData();
formData.append('content', data.content);
data.images.forEach((e, i) => formData.append('images', e));
const response = await fetch('url', {
method: 'POST',
body: formData,
});
Steps to reproduce
const formData = new FormData();
formData.append('content', data.content);
data.images.forEach((e, i) => formData.append('images', e));
const response = await fetch('url', {
method: 'POST',
body: formData,
});
React Native Version
0.85.0
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
System:
OS: Linux 6.12 Debian GNU/Linux 13 (trixie) 13 (trixie)
CPU: (4) x64 Intel(R) Core(TM) i3-3217U CPU @ 1.80GHz
Memory: 2.34 GB / 7.63 GB
Shell:
version: 5.2.37
path: /bin/bash
Binaries:
Node:
version: 24.12.0
path: /usr/local/bin/node
Yarn: Not Found
npm:
version: 11.11.1
path: /usr/local/bin/npm
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "34"
- "35"
- "36"
Build Tools:
- 33.0.0
- 34.0.0
- 35.0.0
- 36.0.0
Android NDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java:
version: 17.0.17
path: /usr/bin/javac
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 20.1.3
wanted: 20.1.3
react:
installed: 19.2.3
wanted: 19.2.3
react-native:
installed: 0.85.0
wanted: 0.85.0
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Stacktrace or Logs
TypeError: Network request failed
at anonymous (fetch.umd.js:567:31)
MANDATORY Reproducer
https://github.com/AlexCernik/rn-formdata-reproducer
Screenshots and Videos
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行强制复现程序,并检查在 Android 上使用 FormData 发送图像 URI 的 fetch 调用。跟踪该请求使用的 React Native 网络路径,并将其行为与报告的 Network request failed 错误进行比较。当复现程序能够在 React Native 0.85.0 上成功上传图像时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, javascript, react-native
- 领域
- mobile, networking
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100