{"id":21518148,"url":"https://github.com/ucloud/ufile-sdk-ios","last_synced_at":"2026-03-15T17:17:25.874Z","repository":{"id":56924720,"uuid":"162395777","full_name":"ucloud/ufile-sdk-ios","owner":"ucloud","description":"UCloud 对象存储官方 SDK","archived":false,"fork":false,"pushed_at":"2023-07-13T04:10:49.000Z","size":28199,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-11T21:03:56.177Z","etag":null,"topics":["library","object-storage","objective-c","ucloud-sdk"],"latest_commit_sha":null,"homepage":"https://www.ucloud.cn/","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ucloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-19T06:57:10.000Z","updated_at":"2025-05-06T09:01:04.000Z","dependencies_parsed_at":"2025-04-09T21:55:16.054Z","dependency_job_id":null,"html_url":"https://github.com/ucloud/ufile-sdk-ios","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/ucloud/ufile-sdk-ios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucloud%2Fufile-sdk-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucloud%2Fufile-sdk-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucloud%2Fufile-sdk-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucloud%2Fufile-sdk-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ucloud","download_url":"https://codeload.github.com/ucloud/ufile-sdk-ios/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ucloud%2Fufile-sdk-ios/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264248022,"owners_count":23579059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","object-storage","objective-c","ucloud-sdk"],"created_at":"2024-11-24T00:50:17.746Z","updated_at":"2026-03-15T17:17:25.856Z","avatar_url":"https://github.com/ucloud.png","language":"Objective-C","readme":"# US3 SDK for iOS\n\n[![Software License](https://img.shields.io/github/license/saltstack/salt)](LICENSE)\n\n\n## 概要\n\n![](https://camo.githubusercontent.com/86885d3ee622f43456c8b890b56c3f05d6ec2c5e/687474703a2f2f636c692d75636c6f75642d6c6f676f2e73672e7566696c656f732e636f6d2f75636c6f75642e706e67)\n\n本文档主要是`US3 (原名UFile) SDK for iOS`的使用说明文档，下面我们从以下几个方面做介绍： \n\n* 目录结构\n* 环境要求\n* 安装使用\n* 功能说明\n* 常见问题\n* 联系我们\n\n## 目录结构\n\n该仓库主要包括`SDK`的源码以及示例项目，示例项目包含`Objective-C`和`Swift`两个版本。 \n\n目录  | 说明\n------------- | -------------\n`SDK/UFileSDK` | SDK源码\n`SDK/UFileSDK/UFileSDKTests` | SDK各个功能的单元测试\n`SDK/documents/devDocuments.zip` | SDK开发文档(解压后可用浏览器查看)\n`SDK/Demos/OC/UFileSDKDemo` | Demo程序(`Objective-c`版本)\n`SDK/Demos/Swift/UFileSDKDemo-swift` | Demo程序(`Swift`版本)\n\n## 环境要求\n\n* iOS系统版本\u003e=11.0\n* 必须是`UCloud`的用户，并开通了`US3`服务。\n\n## 安装使用\n\n### cocoapods方式\n\n在你项目的`Podfile`中加入以下依赖：\n\n```\npod 'UFileSDK'\n```\n\n### 使用方法\n\n在工程中引入头文件:\n\n```\n#import \u003cUFileSDK/UFileSDK.h\u003e\n```\n\n注意，引入Framework后，需要在工程`Build Settings`的`Other Linker Flags`中加入`-lc++` 。如下图所示\n\n![](https://raw.githubusercontent.com/ucloud/ufile-sdk-ios/master/documents/resources/readme_01.png)\n\n## 功能说明\n\n### 文件操作功能\n\n * 文件上传(以路径方式；以NSData方式；分片上传)\n * 文件下载(下载指定范围文件数据；下载整个文件；下载文件到路径)\n * 查询文件\n * 删除文件\n * 获取`bucket`下的文件列表(全部文件列表；指定前缀等条件的文件列表)\n * 获取`bucket`下文件的下载地址(公有`bucket`空间下文件下载地址；私有`bucket`空间下文件下载地址)\n * 获取文件的headfile信息(包括文件的mimetype,etag等)\n * 获取文件的`Etag`\n * 对比本地与远程文件的`Etag`\n\n其操作类是`UFFileClient.h`,以上各个功能详细使用方法请查看[SDK单元测试](https://github.com/ucloud/ufile-sdk-ios/blob/master/UFileSDK/UFileSDKTests/UFFileClientTests.m)或者我们提供的[Demo](https://github.com/ucloud/ufile-sdk-ios/tree/master/Demos)\n\n### 后台下载功能\n\n* 在项目的 Capability 中启用 Background Modes -\u003e 勾选Background fetch.\n* 在AppDelegate里添加下面的代码：\n```\n// 后台下载任务全部完成时回调\n- (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)(void))completionHandler;\n```\n\n### 代码示例\n\n#### 文件管理\n\n假设此时，US3的控制台上你已经创建好了`Bucket`。下面我们介绍一下如何进行文件操作。\n\n首先创建一个文件操作类,需要传入配置信息(主要是`bucket`配置信息)：\n\n```\n#import \u003cUFileSDK/UFileSDK.h\u003e\n\n // 使用本地签名，不推荐使用这种方式\nUFConfig *ufConfig = [UFConfig instanceConfigWithPrivateToken:@\"bucket私钥\" publicToken:@\"bucket公钥\" bucket:@\"bucket名称\" fileOperateEncryptServer:nil fileAddressEncryptServer:nil proxySuffix:@\"域名后缀\" customDomain:nil isHttps:YES];\n    \n // 使用服务器签名，推荐使用\nUFConfig *ufConfig = [UFConfig instanceConfigWithPrivateToken:nil publicToken:@\"bucket公钥\" bucket:@\"bucket名称\" fileOperateEncryptServer:@\"文件操作签名服务器\" fileAddressEncryptServer:@\"获取文件URL的签名服务器\" proxySuffix:@\"域名后缀\" customDomain:nil isHttps:YES];\n \n // 使用自定义域名（优先级高于默认域名）\nUFConfig *ufConfig = [UFConfig instanceConfigWithPrivateToken:@\"bucket私钥\" publicToken:@\"bucket公钥\" bucket:@\"bucket名称\" fileOperateEncryptServer:nil fileAddressEncryptServer:nil proxySuffix:nil customDomain:@\"https://cdn.example.com\" isHttps:YES];\nUFFileClient *fileClient =  [UFFileClient instanceFileClientWithConfig:ufConfig];\n\n```\n\n文件管理操作时，你所操作的`bucket`空间就是你在创建`UFFileClient`时所配置的`bucket`。下面我们示例一个简单的文件上传：\n\n```\n// 上传文件(以路径方式)\nNSString*  fileName = @\"initscreen.jpg\";\nNSString* strPath = [[NSBundle mainBundle] pathForResource:@\"initscreen\" ofType:@\"jpg\"];\n    \n[_fileClient uploadWithKeyName:fileName filePath:strPath mimeType:@\"image/jpeg\" progress:^(NSProgress * _Nonnull progress) {\n        \n    } uploadHandler:^(UFError * _Nullable ufError, UFUploadResponse * _Nullable ufUploadResponse) {\n    if(!ufError){\n    \t// 你的上传成功逻辑\n\t   return;\n    }\n    // 根据ufError处理失败信息\n    }];\n```\n\n### 服务器签名\n\n此处特别强调：我们推荐使用服务端签名。 服务端签名示例代码地址 [ufile-sdk-auth-server](https://github.com/ucloud/ufile-sdk-auth-server) ,你可以直接把它部署到你的服务器上配置好参数后在移动端使用。\n\n### Demo程序\n\n我们在demo程序中，演示了文件操作的所有功能，你可以在本工程中查看其具体流程。另外，为了能更好的理解并使用`UFile SDK`，我们在此还提供了[UFileSDKDemo说明文档](https://github.com/ucloud/ufile-sdk-ios/blob/master/documents/DemoIntroduction.md)\n\n\n## 常见问题\n\n* `iOS 9+`强制使用`HTTPS`,使用`XCode`创建的项目默认不只支持`HTTP`，所以需要在`project build info` 添加`NSAppTransportSecurity`,在`NSAppTransportSecurity`下添加`NSAllowsArbitraryLoads`值设为`YES`,如下图。 \n\t![](https://raw.githubusercontent.com/ucloud/ufile-sdk-ios/master/documents/resources/readme_02.png)\n\t\n## 版本记录\n\n[UFileSDK release history](https://github.com/ucloud/ufile-sdk-ios/blob/master/documents/update.md)\n\n## 联系我们\n\n* [UCloud官方网站: https://www.ucloud.cn/](https://www.ucloud.cn/)\n*  如有任何问题，欢迎提交[issue](https://github.com/ucloud/ufile-sdk-ios/issues)或联系我们的技术支持，我们会第一时间解决问题。\n\n## 许可证\n[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html)      \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucloud%2Fufile-sdk-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fucloud%2Fufile-sdk-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fucloud%2Fufile-sdk-ios/lists"}