Multiple clouds, one Kotlin Multiplatform bridge. Currently supporting web and desktop (JVM), but Android and iOS support is planned.
This library is not yet stable. The API will change and docs may be outdated.
- ⚡ Unified: One library to access Dropbox, Google Drive and OneDrive.
- 🪶 Lightweight: No need to integrate different SDKs for different platforms.
- 📱 Cross-platform: Currently supports web, but mobile (Android) and desktop (JVM) are planned.
Limited access scopes by using app folders are preferred by the library wherever possible.
| Mobile (Android) |
Mobile (iOS) |
Desktop (JVM) |
Web (JS/WASM) |
|
|---|---|---|---|---|
| Dropbox | ⏳ | ⏳ | ✅ | ✅ |
| Google Drive | ⏳ | ⏳ | ✅ | ✅ |
| Microsoft OneDrive | ⏳ | ⏳ | ✅ | ✅ |
✅ = Supported.
⏳ = Planned.
See Compatibility.md for important remarks about each service.
- Folders
- List content
- Create/delete folder
- Files
- Create/update/delete file
- Download file content
- User
- Get name and email address
See Compatibility.md for details.
The library is published to Maven Central.
dependencies {
implementation("nl.jacobras:cloudbridge:0.5.0")
}The main entry point is CloudBridge.dropbox(), CloudBridge.googleDrive() or CloudBridge.oneDrive().
Here's an example with Dropbox. First instantiate the service:
val service = CloudBridge.dropbox() // Pass in token=... if you already have oneThen, have the user authenticate.
Desktop
val authServer = LocalAuthenticationServer()
// Build auth URL and open it in the browser
val url = service.authenticate(
authServer = authServer,
clientId = "yourClientId",
onSuccess = { token -> TODO() })
openBrowser(url)Web
service.completeAuthentication() // Always call this
// When user wants to authenticate:
service.startAuthenticationByRedirect(
clientId = "yourClientId",
redirectUri = "yourRedirectUri"
)Securely store the token and pass it to the constructor of the service to use it.
val service = CloudBridge.dropbox(clientId = "yourClientId")
try {
service.listFiles()
} catch (e: CloudServiceException) {
// Handle...
}The library only supports limited/private app folders, no full access.
The library prefers to work with IDs over paths.
Only one account per service is supported as of now.
id and path variables are typed as much as possible, to prevent accidental mix-ups.
Dropbox will throw 409 when it can't find a path. Other services throw
404 CloudBridge turns them both into CloudServiceException.NotFoundException.
Feel free to open an issue if you have a different use case for any of these.
Next to Kotlin Multiplatform, this library uses:
- Ktor and Ktorfit for network requests.
- KotlinCrypto hash for SHA256 hashing.
- multiplatform-settings to persist tokens.
- urlencoder for URL encoding.
