appwrite / appwrite/sdk-for-react-native

Storage createFile fails on Expo SDK 57 with "Unsupported FormDataPart implementation"

Open
#115 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.3k
Forks
36
Avg merge
2h 50m
Merged PRs (30d)
1

Description

**Environment**

- react-native-appwrite 0.32.0 (the upload code is the same in 0.34.0)
- expo ~57.0.18, react-native 0.86.3, Android device, new architecture
- Appwrite Cloud

**What happens**

```ts
await storage.createFile({
bucketId,
fileId: ID.unique(),
file: { name: pdf.name, type: 'application/pdf', size: pdf.size, uri: pdf.uri },
permissions: [Permission.read(Role.user(userId))],
});
```

rejects with an `AppwriteException` whose message is `Unsupported FormDataPart implementation` (code 0, type empty). No request reaches Appwrite. The `uri` is a `file://` path in the app cache returned by `expo-document-picker`.

**Why**

Expo SDK 57 installs `expo/fetch` as the global `fetch` on native (`expo/src/winter/runtime.native.ts`; the opt-out is `EXPO_PUBLIC_USE_RN_FETCH=1`). Its multipart encoder, `expo/src/winter/fetch/convertFormData.ts`, accepts string parts, `Blob` parts and objects exposing `bytes()`, and throws `Unsupported FormDataPart implementation` for anything else. Its own header comment states that `uri` is not supported for React Native's FormData.

`Client.call` appends the file to a React Native `FormData` as `{ uri, name, type }` (`dist/esm/sdk.js`, the `multipart/form-data` branch around line 610). The chunked path for files above 5 MB does the same with a `data:` URI on iOS and a temp file on Android (around line 4200). Both shapes now throw before the request is sent.

**Workaround**

Set `EXPO_PUBLIC_USE_RN_FETCH=1` so Expo keeps React Native's fetch, which understands `{ uri }` parts.

**Suggested fix**

The SDK already depends on `expo-file-system`. Building the part from `new File(uri)` (it exposes `bytes()`, `name`, `type` and `size`) or from a `Blob` would work under both fetch implementations. Related: #112 covers the removed legacy FileSystem import on SDK 55.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the multipart/form-data branches in dist/esm/sdk.js, including the normal and chunked file paths, and compare their parts with Expo's rules in expo/src/winter/fetch/convertFormData.ts. Reproduce the documented upload on Expo SDK 57 with both fetch implementations; done means normal and chunked uploads no longer fail before reaching Appwrite.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
api, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.