-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Description
Description
When attempting to upload a file using FormData on Android, the request immediately fails with a generic Network Error (or TypeError: Network request failed with fetch). The same code works perfectly on iOS.
`export type CreateAgencyTimelineParams = {
agency?: Iri<API.AGENCIES>
/**
* Should be a File
*/
file?: any | undefined
status: Iri<API.TIMELINE_STATUSES>
comment: string
parent?: string | null
tags?: string[]
}
export function createAgencyTimeline(
params: CreateAgencyTimelineParams,
config?: ExtendedAxiosRequestConfig
) {
const form = new FormData()
form.append('agency', params.agency as string)
form.append('comment', params.comment)
form.append('status', params.status as string)
if (!!params.parent?.length) form.append('parent', params.parent as string)
if (params.file) {
form.append('file', params.file)
}
if (params.tags && params.tags.length > 0) {
params.tags.forEach(tag => form.append('tags[]', tag))
}
return (config?.instance ?? axios).post('/api/agency/timelines-simple', form, {
...(config ?? {}),
transformRequest: data => {
return data
}
})
}`
Steps to reproduce
Pick a file using a library like react-native-image-picker or expo-image-picker on an Android Emulator or device.
Construct a FormData object and append a file using the standard React Native format:
JavaScript
const formData = new FormData();
formData.append('file', {
uri: file.uri, // Ensure it starts with file:///
type: 'image/jpeg',
name: 'photo.jpg',
});
Execute a POST request using Axios (with a custom instance) or Fetch to a remote server.
Observe the result: On iOS, the request is successful. On Android, it immediately throws a Network Error before even hitting the server (no outgoing traffic visible in server logs).
React Native Version
0.84.0
Affected Platforms
Runtime - Android
Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: macOS 26.3
CPU: (12) arm64 Apple M4 Pro
Memory: 2.43 GB / 24.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 24.13.0
path: ~/.nvm/versions/node/v24.13.0/bin/node
Yarn:
version: 4.8.1
path: ~/.nvm/versions/node/v24.13.0/bin/yarn
npm:
version: 8.19.4
path: ~/Developer/studiosystems-monorepo/node_modules/.bin/npm
Watchman:
version: 2024.12.02.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /Users/emrekartici/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 25.2
- iOS 26.2
- macOS 26.2
- tvOS 26.2
- visionOS 26.2
- watchOS 26.2
Android SDK:
API Levels:
- "33"
- "34"
- "35"
- "36"
Build Tools:
- 34.0.0
- 35.0.0
- 36.0.0
System Images:
- android-34 | Google APIs ARM 64 v8a
- android-35 | Google Play ARM 64 v8a
- android-36 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2024.3 AI-243.26053.27.2432.13536105
Xcode:
version: 26.2/17C52
path: /usr/bin/xcodebuild
Languages:
Java:
version: 21.0.6
path: /usr/bin/javac
Ruby:
version: 2.7.8
path: /Users/emrekartici/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.1.0
wanted: 20.1.0
react:
installed: 19.2.3
wanted: 19.2.3
react-native:
installed: 0.84.0
wanted: 0.84.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
Network error
MANDATORY Reproducer
/
Screenshots and Videos
No response