• Stars
    star
    436
  • Rank 99,877 (Top 2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 10 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Qiniu Resource (Cloud) Storage Objective-C SDK for Mac/iOS

Qiniu Resource Storage SDK for Objective-C

@qiniu on weibo Software License Build Status Badge w/ Version GitHub release codecov Platform

安装

通过 CocoaPods

pod "Qiniu", "~> 8.5.3" 

通过 Swift Package Manager (Xcode 11+)

App 对接:
File -> Swift Packages -> Add Package Dependency,输入库链接,选择相应版本即可
库链接: https://github.com/qiniu/objc-sdk

库对接:
let package = Package(
    dependencies: [
        .package(url: "https://github.com/qiniu/objc-sdk", from: "8.5.3")
    ],
    // ...
)

运行环境

Qiniu SDK 版本 最低 iOS版本 最低 OS X 版本 Notes
8.5.x iOS 7 OS X 10.15 Xcode 最低版本 11
8.4.x iOS 7 OS X 10.15 Xcode 最低版本 11
8.3.x iOS 7 OS X 10.15 Xcode 最低版本 11
8.2.x iOS 7 OS X 10.15 Xcode 最低版本 11
8.1.x iOS 7 OS X 10.15 Xcode 最低版本 11
8.0.x iOS 7 OS X 10.15 Xcode 最低版本 11
7.5.x iOS 7 OS X 10.9 Xcode 最低版本 6.
7.4.x iOS 7 OS X 10.9 Xcode 最低版本 6.
7.3.x iOS 7 OS X 10.9 Xcode 最低版本 6.
7.2.x iOS 7 OS X 10.9 Xcode 最低版本 6.
7.1.x / AFNetworking-3.x iOS 7 OS X 10.9 Xcode 最低版本 6.
7.0.x / AFNetworking-2.x iOS 6 OS X 10.8 Xcode 最低版本 5.
7.x / AFNetworking-1.x iOS 5 OS X 10.7 Xcode 最低版本 5.
6.x iOS 6 None Xcode 最低版本 5.

使用方法

简单上传

#import <QiniuSDK.h>
...
    NSString *token = @"从服务端SDK获取";
    QNUploadManager *upManager = [[QNUploadManager alloc] init];
    NSData *data = [@"Hello, World!" dataUsingEncoding : NSUTF8StringEncoding];
    [upManager putData:data key:@"hello" token:token
        complete: ^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
        NSLog(@"%@", info);
        NSLog(@"%@", resp);
    } option:[QNUploadOption defaultOptions]];
...

如使用最新版的sdk,默认自动判断上传空间。如需要指定上传区域,可以按如下方式上传:

#import <QiniuSDK.h>
...
    QNConfiguration *config = [QNConfiguration build:^(QNConfigurationBuilder *builder) {
        builder.useHttps = NO;// 是否使用https
        builder.zone = [QNFixedZone zone0];// 指定华东区域
        // builder.zone = [QNFixedZone zone1];// 指定华北区域
        // builder.zone = [QNFixedZone zone2];// 指定华南区域
        // builder.zone = [QNFixedZone zoneNa0];// 指定北美区域
        // builder.zone = [QNFixedZone zoneAs0];// 指定东南亚区域
    }];
    
    QNUploadManager *upManager = [[QNUploadManager alloc] initWithConfiguration:config];
    QNUploadOption *option = [[QNUploadOption alloc] initWithProgressHandler:^(NSString *key, float percent) {
        NSLog(@"progress %f", percent);
    }];
    
    NSData *data = [@"Hello, World!" dataUsingEncoding:NSUTF8StringEncoding];
    NSString *token = @"从服务端SDK获取";
    [upManager putData:data key:@"hello" token:token complete: ^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
        NSLog(@"%@", info);
        NSLog(@"%@", resp);
    } option:option];
...

建议 QNUploadManager 创建一次重复使用, 或者使用单例方式创建.

测试

所有测试

$ xcodebuild test -workspace QiniuSDK.xcworkspace -scheme QiniuSDK_Mac -configuration Release -destination 'platform=macOS,arch=x86_64'

指定测试

可以在单元测试上修改, 熟悉 SDK

$ xcodebuild test -workspace QiniuSDK.xcworkspace -scheme QiniuSDK_Mac -configuration Release -destination 'platform=macOS,arch=x86_64' -only-testing:"QiniuSDK_MacTests/QNResumeUploadTest/test5M"

示例代码

  • 完整的demo 见 QiniuDemo 目录下的代码
  • 具体细节的一些配置 可参考 QiniuSDKTests 下面的一些单元测试,以及源代码

常见问题

  • 如果碰到 crc 链接错误, 请把 libz.dylib 加入到项目中去
  • 如果碰到 res_9_ninit 链接错误, 请把 libresolv.dylib 加入到项目中去
  • 如果需要支持 iOS 5 或者支持 RestKit, 请用 AFNetworking 1.x 分支的版本
  • 如果碰到其他编译错误, 请参考 CocoaPods 的 troubleshooting
  • iOS 9+ 强制使用https,需要在project build info 添加NSAppTransportSecurity类型Dictionary。在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES。 具体操作可参见 http://blog.csdn.net/guoer9973/article/details/48622823
  • 上传返回错误码理解,status code 注释

代码贡献

详情参考 代码提交指南.

贡献记录

联系我们

  • 如果需要帮助, 请提交工单 (在 portal 右侧点击咨询和建议提交工单, 或者直接向 [email protected] 发送邮件)
  • 如果有什么问题, 可以到问答社区提问, 问答社区
  • 更详细的文档, 见 官方文档站
  • 如果发现了 bug, 欢迎提交 issue
  • 如果有功能需求, 欢迎提交 issue
  • 如果要提交代码, 欢迎提交 pull request
  • 欢迎关注我们的 微信 && 微博, 及时获取动态信息

代码许可

The MIT License (MIT). 详情见 License 文件.

More Repositories

1

js-sdk

Qiniu Cloud JavaScript SDK
JavaScript
1,378
star
2

logkit

Very powerful server agent for collecting & sending logs & metrics with an easy-to-use web console.
Go
1,350
star
3

qmgo

Qmgo - The Go driver for MongoDB. It‘s based on official mongo-go-driver but easier to use like Mgo.
Go
1,297
star
4

qshell

Shell Tools for Qiniu Cloud
Go
980
star
5

php-sdk

Qiniu Resource (Cloud) Storage SDK for PHP
PHP
810
star
6

goc

A Comprehensive Coverage Testing System for The Go Programming Language
Go
796
star
7

httptest

Qiniu httptest utilities
Go
635
star
8

android-sdk

Qiniu Resource (Cloud) Storage SDK for Android
Java
626
star
9

nodejs-sdk

Qiniu Resource (Cloud) Storage SDK for Node.js
JavaScript
587
star
10

java-sdk

Qiniu Resource (Cloud) Storage SDK for Java
Java
549
star
11

python-sdk

Qiniu Resource (Cloud) Storage SDK for Python
Python
543
star
12

happy-dns-objc

dns library for objective c
Objective-C
491
star
13

iconv

Golang bindings to libiconv - Convert string to requested character encoding
Go
474
star
14

arch

极客时间专栏《许式伟的架构课》相关的源代码:冯诺伊曼结构
Go
407
star
15

cerl

CERL2.0 - Erlang Model for C++
C++
376
star
16

gobook

The Go Programming Language
Go
362
star
17

py

Golang bindings to the CPython C-API
Go
319
star
18

qetag

qetag
Erlang
316
star
19

happy-dns-android

dns library for android
Java
293
star
20

QSunSync

七牛云文件同步图形化工具-Windows版本
C#
271
star
21

api.v7

Qiniu SDK for Golang (v7.x)
Go
264
star
22

csharp-sdk

Qiniu Resource (Cloud) Storage SDK for C#
C#
176
star
23

qpaint

极客时间专栏《许式伟的架构课》相关的源代码:QPaint (画图程序)
JavaScript
170
star
24

ruby-sdk

Qiniu Resource (Cloud) Storage SDK for Ruby
Ruby
164
star
25

kodo-browser

Kodo Browser 为七牛对象存储(Kodo)提供类似 Windows 资源管理器的功能。用户可以很方便的浏览文件,上传下载文件,支持断点续传等。
TypeScript
159
star
26

iOS-netdiag

Network Diagnosis for iOS
Objective-C
144
star
27

android-netdiag

Network Diagnosis for Android
Java
136
star
28

go-sdk

golang sdk
Go
136
star
29

webhook

Github.com webhook tools
Go
131
star
30

checkstyle

checkstyle for go
Go
128
star
31

legacy-ios-sdk

Qiniu Resource (Cloud) Storage SDK for iOS
Objective-C
103
star
32

QStreaming

A simplified, lightweight ETL pipeline framework for build stream/batch processing applications on top of Apache Spark
Scala
101
star
33

audio

Audio support for Go language.
Go
79
star
34

api.v6

Qiniu Resource (Cloud) Storage SDK for Golang (v6.x)
Go
68
star
35

c-sdk

Qiniu Resource (Cloud) Storage SDK for C/C++
C
63
star
36

x

Extension of Go standard library
Go
62
star
37

http

Extension module of golang http service
Go
61
star
38

qfetch

七牛资源批量抓取工具,根据指定URL列表抓取资源并存储到七牛云空间。
Go
59
star
39

qplayer-sdk

七牛播放器SDK支持点播,直播,首开快,延迟低,接口简单,易于使用。
Java
57
star
40

qiniutest

Qiniu httptest tool: qiniutest
Go
37
star
41

builder

TypeScript
34
star
42

text

Qiniu Text Processing Libraries for Go
Go
34
star
43

ip17mon-java

17mon ip库查询
Java
33
star
44

formstate-x

Manage state of form with ease.
TypeScript
33
star
45

developer.qiniu.com

developer center
JavaScript
32
star
46

mockhttp.v1

mockhttp is a unit test tool that allow you test web services without listening port
Go
29
star
47

form-upload

Form upload demo for Qiniu Cloud Storage
Python
28
star
48

happy-dns-java

dns query client for java
Java
27
star
49

qiniu-logging-plugin

轻松输出Java应用日志到七牛云大数据日志平台
Java
26
star
50

rust-sdk

Generic Qiniu Resource Storage SDK
Rust
26
star
51

dart-sdk

Qiniu Resource (Cloud) Storage SDK for Dart
Dart
23
star
52

sdkspec

Qiniu Resource (Cloud) Storage SDK Specification
23
star
53

pandora-go-sdk

Go
21
star
54

doxygen.io

http://doxygen.io/ - Doxygen as Service
Go
19
star
55

go_dep_search

golang dependency search tool
Go
19
star
56

typed-less-modules

🎁 Generate type definitions (.d.ts) for CSS Modules using LESS
TypeScript
18
star
57

QiniuLiveWX

七牛直播、播放、连麦最简微信小程序demo
JavaScript
17
star
58

mockhttp.v2

mockhttp is a unit test tool that allow you test web services without listening port
Go
16
star
59

qlive

七牛直播命令行工具
Go
15
star
60

objc-DownloadSDK

Qiniu DownloadSDK for iOS
Objective-C
14
star
61

dyn

Package for dynamic programming
Go
12
star
62

reviewbot

reviewbot - establish software engineering best practices and efficiently promote them within the organization.
Go
12
star
63

pandora-java-sdk

Pandora Java SDK 多种方式灵活接入Pandora 大数据平台
Java
11
star
64

goplus-dt

Data Technology base of the Go+ language
Go
9
star
65

pandora-docs-old

CSS
9
star
66

kirk

Go
9
star
67

c-sdk-for-windows

Qiniu Resource (Cloud) Storage Windows SDK for C/C++
C
8
star
68

qwebtesttool

七牛本地网络环境检测图形界面。
C#
8
star
69

pandora-docs

pandora 文档站
JavaScript
7
star
70

php5.3-sdk

七牛云存储 php5.3 sdk(已经过时,请使用 php-sdk)
PHP
7
star
71

version

Go
6
star
72

qfetch-m3u8

qfetch m3u8专用版本,可以把m3u8和其引用的ts文件直接抓取到七牛云存储空间中
Go
6
star
73

openacc

Open Account System
6
star
74

api

Qiniu Resource (Cloud) Storage SDK for Golang
6
star
75

pandora-js-sdk

浏览器端使用的Pandora 大数据客户端打点SDK
JavaScript
6
star
76

deprecated-js-sdk

Qiniu Resource Storage SDK for JavaScript(deprecated)
JavaScript
6
star
77

docs.qiniu.com

CSS
5
star
78

eslint-config

ESLint config for Qiniu
JavaScript
5
star
79

php5-sdk

七牛云存储 PHP SDK,兼容 PHP 5.3 以下版本(已经过时,请使用 php-sdk)
PHP
5
star
80

httpping

http ping for test service
Go
5
star
81

link-c-sdk

qnlinking
C
5
star
82

QNLiveKit_Android

qlive-sdk是七牛云推出的一款互动直播低代码解决方案sdk。只需几行代码快速接入互动连麦pk直播。
Kotlin
5
star
83

cpp-sdk

Qiniu Resource Storage C++ SDK
C
4
star
84

objc-netinfo

Get NetworkInfo
Objective-C
4
star
85

pandora-python-sdk

Python
4
star
86

apidoc

Qiniu Resource (Cloud) Storage API Documents
4
star
87

kubernetes-csi-driver

CSI Plugin for Kubernetes, Support Qiniu Cloud Storage.
Go
4
star
88

qiniulab

C#
3
star
89

stack-go

七牛云主机服务 Go SDK
Go
3
star
90

Android-Universal-Image-Loader-HappyDns

Android-Universal-Image-Loader and happy dns
Java
3
star
91

kodo-enterprise-image

Shell
3
star
92

pfop

七牛持久化数据处理请求服务工具
Go
3
star
93

pandora-python-sdk.v2

SDK for Pandora 2.0
Python
3
star
94

raven

TypeScript
3
star
95

api-specs

Qiniu API Specs by YAML
3
star
96

pandora-php-sdk

PHP
3
star
97

pandora-nodejs-sdk

JavaScript
3
star
98

wp-sdk

Windows Phone SDK for Qiniu Cloud Storage API[不再维护]
C#
3
star
99

pandora-c-sdk

C/C++ SDK for Pandora Platform
C
2
star
100

rust-download-sdk

七牛下载 Rust SDK,负责下载完整或部分七牛对象。该 SDK 主要服务于专有云场景,对于普通的公有云 / 私有云场景,建议使用 https://github.com/qiniu/rust-sdk
Rust
2
star