Skip to main content


React Native OMH Storage - Dropbox

NPM downloadsNPM versionLicense

Chat on DiscordFollow on Twitter


Prerequisites

Before starting the integration, make sure the following packages are installed and configured:

  • @openmobilehub/storage-core
  • react-native-file-access
  • @react-native-async-storage/async-storage
  • react-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:

  1. Create a new app in Dropbox Console.
  2. Specify <YOUR_APPLICATION_ID>://oauth as your redirect URL for your app.
  3. Enable the account_info.read, files.metadata.read, files.content.write, files.content.read, sharing.write and sharing.read permission for your app.

Secrets

To securely configure the Dropbox storage provider, add the following entry to your project's local.properties file:

android/local.properties
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.

CAVEATS

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