CloudStorageProvider
The CloudStorageProvider defines which cloud storage is used. Currently, only iCloud and Google Drive are supported.
By default, the provider is set based on the device's platform. On iOS, iCloud is used, while on all other platforms, Google Drive is used. This can be overriden by calling setProvider(). You can therefore optionally use Google Drive on iOS, too, instead of iCloud.
import { CloudStorageScope } from 'react-native-cloud-storage';
Definition
enum CloudStorageProvider {
ICloud = 'icloud',
GoogleDrive = 'googledrive',
}
When using pure JavaScript, simply use the corresponding values:
CloudStorage.setProvider('googledrive');
Provider options
The provider options can be set via setProviderOptions(). The following options are available:
CloudStorageProvider.ICloud
scope(CloudStorageScope): The directory scope to use. Default:CloudStorageScope.AppData.documentsMode('icloud' | 'legacy_sandbox'): Defines howCloudStorageScope.Documentsis resolved. Use'icloud'for the iCloudDocumentsfolder (default) or'legacy_sandbox'to use the local app sandboxDocumentsfolder (which was the default before react-native-cloud-storage v3).
If you need to move existing files from legacy sandbox storage into the user-facing iCloud Documents folder, see this migration guide.
CloudStorageProvider.GoogleDrive
accessToken(string): The access token to use. Required.scope(CloudStorageScope): The directory scope to use. Default:CloudStorageScope.AppData.strictFilenames(boolean): If set totrue, the library will check for files with duplicate filenames and throw an error if found. File operations will not be carried out in that case. For more information, see here. Default:false.timeout(number): The timeout in milliseconds for requests. Default: 3000.