Note
Attachment helpers are currently in an alpha state, intended strictly for testing. Expect breaking changes and instability as development continues.
Do not rely on this package for production use.
React Native file system storage adapters for PowerSync attachments.
This package provides LocalStorageAdapter implementations for React Native environments, allowing you to store and retrieve attachment files on device.
npm install @powersync/attachments-storage-react-native
# or
pnpm add @powersync/attachments-storage-react-native
# or
yarn add @powersync/attachments-storage-react-nativeYou'll also need to install one of the supported file system libraries:
Important
Requires Expo 54+
npx expo install expo-file-systemnpm install @dr.pogodin/react-native-fsimport { ExpoFileSystemStorageAdapter } from '@powersync/attachments-storage-react-native';
import { AttachmentQueue } from '@powersync/react-native';
const storageAdapter = new ExpoFileSystemStorageAdapter();
const attachmentQueue = new AttachmentQueue({
powersync: db,
storage: cloudStorage,
storageAdapter
});import { ReactNativeFileSystemStorageAdapter } from '@powersync/attachments-storage-react-native';
import { AttachmentQueue } from '@powersync/react-native';
const storageAdapter = new ReactNativeFileSystemStorageAdapter();
const attachmentQueue = new AttachmentQueue({
powersync: db,
storage: cloudStorage,
storageAdapter
});Both adapters accept an optional storageDirectory parameter:
const storageAdapter = new ExpoFileSystemStorageAdapter('/custom/path/to/attachments/');Both adapters implement the LocalStorageAdapter interface from @powersync/common:
initialize()- Create the storage directory if it doesn't existclear()- Remove all files from the storage directorygetLocalUri(filename)- Get the full path for a filenamesaveFile(filePath, data, options?)- Save data to a filereadFile(filePath, options?)- Read a file as ArrayBufferdeleteFile(filePath)- Delete a filefileExists(filePath)- Check if a file existsmakeDir(path)- Create a directoryrmDir(path)- Remove a directory
| Adapter | Library | Supported Versions |
|---|---|---|
ExpoFileSystemStorageAdapter |
expo-file-system |
>=19.0.0 (Expo 54+) |
ReactNativeFileSystemStorageAdapter |
@dr.pogodin/react-native-fs |
^2.25.0 |
Apache-2.0