plugin-dropbox
Android OMH Storage - Dropbox
Prerequisites
Ensure you have the following packages installed before proceeding with the integration:
(Replace <version> with the latest version number shown in the Maven Central badge above)
Installation
To integrate the Dropbox storage provider into your Android project, follow these steps:
1. Configure Maven Central repository
Ensure Maven Central is included as a repository in your root build.gradle file:
allprojects {
repositories {
mavenCentral()
}
}2. Add dependency for the Dropbox Drive storage provider
Add the dependency for the Dropbox storage provider to your project's build.gradle file:
dependencies {
implementation("com.openmobilehub.android.storage:plugin-dropbox-gms:<version>")
}Configuration
Console App
To access Dropbox APIs, follow these steps to obtain the Client ID:
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, you must first initialize both the OMH Auth Client and OMH Storage Client with the necessary configurations.
val omhAuthClient = DropboxAuthClient(
scopes = arrayListOf("account_info.read", "files.metadata.read", "files.content.write", "files.content.read", "sharing.write", "sharing.read"),
context = context,
appId = BuildConfig.DROPBOX_CLIENT_ID,
)
val omhStorageClient = DropboxOmhStorageFactory().getStorageClient(omhAuthClient)Other methods
Interacting with the Dropbox storage provider follows the same pattern as other storage providers since they all implement the OmhStorageClient 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. However, this behavior is non-deterministic, and sometimes only one new version is added. This is why it is listed under the Caveats section.
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.
Escape Hatch
This plugin provides an escape hatch to access the native Dropbox Android SDK. This allows developers to use the underlying provider's API directly, should they need to access a feature of the provider that is not supported by the OMH plugin.
You can obtain the Dropbox client instances by casting the result of getProviderSdk to DbxClientV2:
import com.dropbox.core.v2.DbxClientV2
...
omhStorageClient.getProviderSdk() as DbxClientV2License
See LICENSE