React Native OMH Storage - Dropbox
Prerequisites
Before starting the integration, make sure the following packages are installed and configured:
@openmobilehub/storage-corereact-native-file-access@react-native-async-storage/async-storagereact-native-app-auth- Configuration@openmobilehub/auth-core- Configuration@openmobilehub/auth-dropbox- Configuration
Installation
npm add @openmobilehub/storage-dropbox
Console App
To access Dropbox APIs, follow these steps to obtain the Client App Key and Client App Secret:
- Create a new app in Dropbox Console.
- Specify
<YOUR_APPLICATION_ID>://oauthas your redirect URL for your app. - Enable the
account_info.read,files.metadata.read,files.content.write,files.content.read,sharing.writeandsharing.readpermission for your app.
Secrets
To securely configure the Dropbox storage provider, add the following entry to your project's local.properties file:
DROPBOX_CLIENT_ID=<YOUR_DROPBOX_APP_KEY>
Usage
Initializing
To interact with the Dropbox storage provider, start by initializing the OMH Auth Client. Once the authentication client is set up, you can then initialize the OMH Storage Client.
import DropboxAuthClient from '@openmobilehub/auth-dropbox';
import { DropboxStorageClient } from '@openmobilehub/storage-dropbox';
const scopes = [
'account_info.read',
'files.metadata.read',
'files.content.write',
'files.content.read',
'sharing.write',
'sharing.read',
];
await DropboxAuth.initialize({
android: { scopes },
ios: {
scopes,
clientId: '<YOUR_DROPBOX_APP_KEY>',
clientSecret: '<YOUR_DROPBOX_APP_SECRET>',
redirectUrl: '<YOUR_REDIRECT_URL>',
},
});
const dropboxStorageClient = new DropboxStorageClient(DropboxAuth);
Other methods
Interacting with the Dropbox storage provider follows the same pattern as other storage providers since they all implement the IStorageClient interface. This uniformity ensures consistent functionality across different storage providers, so you won’t need to learn new methods regardless of the storage provider you choose! For a comprehensive list of available methods, refer to the Getting Started guide.
When updating a file, if the new file has a different name than the updated file, two additional versions might sometimes appear in the system. One version comes from updating the content of the file, and the other comes from updating the file name.
The createPermission method returns null when a permission is successfully created.
The updatePermission method returns null when a permission is successfully updated.
The getWebUrl method requires the folder to be a shared folder to return a web URL.
The getFilePermissions method requires the folder to be a shared folder to retrieve any permissions, including owner permission.
License
- See LICENSE