阿里云盘SDK 0.3.4

AliyunpanSDK 0.3.4

zhaixian 维护。



  • 作者:
  • zhaixian

AliyunpanSDK

这是阿里云盘 OpenAPI 的开源 SDK。

入门指南

要开始使用该 SDK,请访问我们的指南,该指南将指导您完成设置过程。

👉 指南

快速入门

1. 创建客户端

您可以通过使用 PKCE 或服务器凭证来创建客户端。

// 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())))

2. 发送指令

使用此SDK,您可以轻松集成所有公开API及其请求/响应模型。

// Concurrency
try await client.send(
    AliyunpanScope.User.GetUserInfo()) // -> GetUserInfo.Response

try await client.send(
    AliyunpanScope.File.GetFileList(
        .init(drive_id: driveId, parent_file_id: "root")))) // -> GetFileList.Response
        
// Closure
client.send(
    AliyunpanScope.User.GetUserInfo()) { result in
    /// do something
}

高级用法

此外,此SDK还提供了高级功能,以加快您的开发并使其更加平稳。

下载

// Concurrency
let downloader = try await client.downloader(file, to: destination)
for try await result in downloader.download() {
    if let url = result.url {
        // File is downloaded, process the file
    } else {
        // Handle other cases
    }
}

// Closure
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
    }
}

要求

  • iOS 13.0+
  • Swift 5.0+

安装

Swift 包管理器

  • 文件 > Swift 包 > 添加包依赖
  • 添加 https://github.com/alibaba/aliyunpan-ios-sdk.git

CocoaPods

target 'MyApp' do
  pod 'AliyunpanSDK', '~> 0.1.0'
end

文档

👉 文档

授权

本项目采用 MIT 许可证 许可。