React Native Cloud Storage
Hooks

useCloudFile

A utility hook for reading and writing to a single file in the cloud.

function useCloudFile(
   path: string, 
   scope?: CloudStorageScope, 
   cloudStorageInstance?: CloudStorage): object;

A utility hook for reading and writing to a single file in the cloud.

Parameters

ParameterTypeDescription
pathstringThe path to the file.
scope?CloudStorageScopeThe directory scope the path is in. Defaults to the default scope set for the current provider.
cloudStorageInstance?CloudStorageAn optional instance of RNCloudStorage to use instead of the default instance.

Returns

An object containing the file's contents and functions for downloading, reading, writing, and removing the file.

NameTypeDefault valueDescription
contentstring | null-The content of the file.
download()() => Promise<void>syncTriggers synchronization for the file. Needed if the file hasn't been synced yet from iCloud. Has no effect on Google Drive. Deprecated Use sync instead.
read()() => Promise<void>-Reads the file from the cloud.
remove()() => Promise<void>-Deletes the file.
sync()() => Promise<void>-Triggers synchronization for the file. Needed if the file hasn't been synced yet from iCloud. Has no effect on Google Drive.
write()(newContent: string) => Promise<void>-Writes new content to the file.

On this page