Skip to content

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

Description

@SectionTN

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions