This is the open-source SDK for Aliyunpan-Android OpenAPI.
dependencies {
implementation 'com.github.alibaba:aliyunpan-android-sdk:v0.2.2'
}
To begin using the sdk, visit our guide that will walk you through the setup process:
import com.alicloud.databox.opensdk.AliyunpanClient
import com.alicloud.databox.opensdk.AliyunpanClientConfig
fun initApp(context: Context) {
val config = AliyunpanClientConfig.Builder(context, "app_id")
.build()
// init client
val aliyunpanClient = AliyunpanClient.init(config)
}
import com.alicloud.databox.opensdk.AliyunpanClient
import com.alicloud.databox.opensdk.AliyunpanClientConfig
import com.alicloud.databox.opensdk.AliyunpanTokenServer
val config = AliyunpanClientConfig.Builder(context, "app_id")
.tokenServer(object : AliyunpanTokenServer {
// implement some one
})
.build()
// init client
val aliyunpanClient = AliyunpanClient.init(config)
aliyunpanClient.send(AliyunpanUserScope.GetDriveInfo(),
{ result ->
// success
}, {
// failure
})
import com.alicloud.databox.opensdk.kotlin.AliyunpanClient
fun initApp(context: Context) {
// config
val config = AliyunpanClientConfig.Builder(context, "app_id")
.build()
// init client
val aliyunpanClient = AliyunpanClient.init(config)
}
lifecycleScope.launch {
try {
val response = aliyunpanClient.send(AliyunpanUserScope.GetDriveInfo())
} catch (e: Exception) {
}
}
aliyunpanClient.buildDownload(driveId, fileId, { task ->
// success
task.addStateChange { taskState ->
when (taskState) {
BaseTask.TaskState.Abort -> {
}
is BaseTask.TaskState.Completed -> {
}
is BaseTask.TaskState.Failed -> {
}
is BaseTask.TaskState.Running -> {
}
BaseTask.TaskState.Waiting -> {
}
}
}
val startResult = task.start()
}, {
// failure
})
aliyunpanClient.buildUpload(driveId, filePath, { task ->
// success
task.addStateChange { taskState ->
when (taskState) {
BaseTask.TaskState.Abort -> {
}
is BaseTask.TaskState.Completed -> {
}
is BaseTask.TaskState.Failed -> {
}
is BaseTask.TaskState.Running -> {
}
BaseTask.TaskState.Waiting -> {
}
}
}
val startResult = task.start()
}, {
// failure
})
Add it in your root build.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
- minSdk 21
This project is licensed under the MIT License - see the MIT License file for details