This is the open-source SDK for Aliyunpan OpenAPI.
To begin using the sdk, visit our guide that will walk you through the setup process:
You can create a client either by using PKCE or server credentials.
// Using PKCE
let client: AliyunpanClient = AliyunpanClient(
.init(
appId: "YOUR_APP_ID",
scope: "YOUR_SCOPE", // e.g. user:base,file:all:read
credentials: .pkce))
// Using server credentials
class YOUR_SERVER_CLASS: AliyunpanBizServer {
...
}
let client: AliyunpanClient = AliyunpanClient(
.init(
appId: "YOUR_APP_ID",
scope: "YOUR_SCOPE", // e.g. user:base,file:all:read
credentials: .server(YOUR_SERVER_CLASS())))
With this SDK, you can easily interface all openAPIs and their request/response models.
// Concurrency
try await client.send(
AliyunpanScope.User.GetUsersInfo()) // -> GetUsersInfo.Response
try await client.send(
AliyunpanScope.File.GetFileList(
.init(drive_id: driveId, parent_file_id: "root")))) // -> GetFileList.Response
// Closure
client.send(
AliyunpanScope.User.GetUsersInfo()) { result in
/// do something
}
This SDK also provides advanced functionalities to make your development faster and smoother.
let downloader = client.downloader(file, to: destination)
downloader.download { progress in
// do something..
} completionHandle: { result in
if let url = try? result.get() {
// File is downloaded, process the file
} else {
// Handle other cases
}
}
downloader.networkSpeedMonitor = { bytesReceived in
// This closure is called with the number of bytes downloaded in the last second.
// You can use `bytesReceived` to update the UI or perform other actions based on the current network speed.
}
- iOS 13.0+
- Swift 5.0+
- File > Swift Packages > Add Package Dependency
- Add
https://github.com/alibaba/aliyunpan-ios-sdk.git
target 'MyApp' do
pod 'AliyunpanSDK', '~> 0.1.0'
end
This project is licensed under the MIT License.