Files SDK
SDK for working with Cloudike files — upload, sync, and file management.
Applies to Files SDK 5.5.2+
Installation
Declare Cloudike's private Maven repository in your project's settings.gradle.kts (artifactory_username/artifactory_password are credentials provided by Cloudike, set in your own gradle.properties):
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url = uri("https://rt.cloudike.com/artifactory/libs-release-local")
credentials {
username = settings.extra.properties["artifactory_username"].toString()
password = settings.extra.properties["artifactory_password"].toString()
}
}
}
}
Add files and its required core dependency to your app module's build.gradle.kts and sync the project:
dependencies {
implementation("com.cloudike.sdk:files:<version>")
implementation("com.cloudike.sdk:core:<version>")
}
Initialization
import com.cloudike.sdk.core.CoreManager
import com.cloudike.sdk.files.FilesManager
import kotlinx.coroutines.runBlocking
val coreContext = CoreManager.build(applicationContext)
runBlocking {
coreContext.sessionManager.start(
reset = false,
baseUrl = "https://your-backend.example.com/", // your Cloudike backend endpoint
accessToken = accessToken, // from your sign-in flow
userId = userId, // from your sign-in flow
userAgent = "YourApp/1.0",
)
}
val filesManager = FilesManager.build(coreContext)
Builds the shared CoreContext, starts the user session on it, then builds FilesManager on the same CoreContext. baseUrl/accessToken/userId/userAgent come from your own sign-in flow — the values shown are placeholders.
First API Call
import com.cloudike.sdk.files.data.FilesFetchState
import com.cloudike.sdk.files.usecase.FileListUseCase
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
val rootFiles = runBlocking {
// An empty string identifies the partner's root folder — Files SDK's own convention.
filesManager.fileSync.fetchFiles(parentFileId = "")
// fetchFiles only starts the sync — wait until it completes or fails.
val syncState = filesManager.fileSync.fetchFilesStateFlow
.first { it is FilesFetchState.Complete || it is FilesFetchState.Error }
if (syncState is FilesFetchState.Error) throw syncState.throwable
filesManager.fileListing
.getFilesByParentIdAsFlow(parentId = "", sortType = FileListUseCase.SortType.NO_SORTING)
.first()
}
println("Root folder items: ${rootFiles.size}")
fetchFiles only starts syncing the root folder and returns right away — the sync itself runs in the background, and its completion or failure is reported through fetchFilesStateFlow, never thrown.
The example waits for Complete, rethrows the throwable of an Error, and only then reads the root folder's list.
An empty string parentId/parentFileId denotes the partner's root folder.
A successful result — the root folder's items, possibly none if the account has no files yet — confirms Files SDK can sync and read data from the account.