API Reference
Constants
| Export | Type | Description |
|---|---|---|
defaultICloudContainerPath | string | null | Absolute path to the app's iCloud container. It is null when the container is unavailable. |
The module stores files under the app's iCloud Documents directory. Build full paths with:
const iCloudDocumentsPath = `${defaultICloudContainerPath}/Documents`;Availability
isICloudAvailableAsync()
function isICloudAvailableAsync(): Promise<boolean>;Returns true when the current user has an iCloud identity token available on the device.
Directory and existence
createDirAsync(path)
function createDirAsync(path: string): Promise<boolean>;Creates a directory relative to the app's iCloud Documents directory. Intermediate directories are created.
readDirAsync(path, options)
function readDirAsync(
path: string,
options?: { isFullPath?: boolean }
): Promise<string[]>;Reads a directory relative to iCloud Documents.
By default, isFullPath is true, so returned values are full paths. Set isFullPath: false to return only file names.
isExistAsync(path, isDirectory)
function isExistAsync(path: string, isDirectory: boolean): Promise<boolean>;Checks whether a file or directory exists relative to iCloud Documents.
Upload
uploadFileAsync(options)
function uploadFileAsync(options: {
destinationPath: string;
filePath: string;
}): Promise<string>;Uploads a local file to a destination path relative to iCloud Documents.
The parent directory must already exist. Create it with createDirAsync() before uploading.
filePath can be an Expo FileSystem file:// URI or a plain local filesystem path.
uploadFilesAsync(options)
type ICloudFileOperationResult = {
success: boolean;
path?: string;
error?: string;
};
function uploadFilesAsync(options: {
destinationDirectory: string;
filePaths: string[];
}): Promise<ICloudFileOperationResult[]>;Uploads multiple local files into a destination directory relative to iCloud Documents.
The destination directory must already exist.
Each filePaths entry can be an Expo FileSystem file:// URI or a plain local filesystem path.
Download
downloadFileAsync(path, destinationDir)
function downloadFileAsync(
path: string,
destinationDir: string
): Promise<string>;Downloads a full iCloud file path into a local destination directory.
destinationDir can be an Expo FileSystem file:// URI or a plain local filesystem path.
downloadFilesAsync(paths, destinationDir)
function downloadFilesAsync(
paths: string[],
destinationDir: string
): Promise<ICloudFileOperationResult[]>;Downloads multiple full iCloud file paths into a local destination directory.
destinationDir can be an Expo FileSystem file:// URI or a plain local filesystem path.
Delete
unlinkAsync(path)
function unlinkAsync(path: string): Promise<boolean>;Deletes a full iCloud path.
Progress events
addUploadFilesAsyncProgressListener(listener)
function addUploadFilesAsyncProgressListener(
listener: (event: { value: number }) => void
): Subscription;Listens for upload progress events. value is a number from 0 to 100.
addDownloadFilesAsyncProgressListener(listener)
function addDownloadFilesAsyncProgressListener(
listener: (event: { value: number }) => void
): Subscription;Listens for download progress events. value is a number from 0 to 100.
Path utilities
PathUtils.iCloudRemoveDotExt(path)
PathUtils.iCloudRemoveDotExt("photo.heic.icloud"); // "photo.heic"Removes the .icloud placeholder extension from a path.
PathUtils.ext(path)
PathUtils.ext("archive.backup.zip"); // "zip"Returns the last extension segment.
