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
| Parameter | Type | Description |
|---|---|---|
path | string | The path to the file. |
scope? | CloudStorageScope | The directory scope the path is in. Defaults to the default scope set for the current provider. |
cloudStorageInstance? | CloudStorage | An 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.
| Name | Type | Default value | Description |
|---|---|---|---|
content | string | null | - | The content of the file. |
download() | () => Promise<void> | sync | Triggers 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. |