Latest 7.2.5
Homepage https://github.com/qiniu/objc-sdk
License MIT The MIT License (MIT)

Copyright (c) 2011-2017 qiniu.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Platforms ios 7.0, osx 10.9, requires ARC
Dependencies HappyDNS

Qiniu Resource Storage SDK for Objective-C

@qiniu on weibo
Software License
Build Status
codecov
Latest Stable Version
Platform

安装

通过 CocoaPods

pod "Qiniu", "~> 7.2" 

运行环境

Qiniu SDK 版本 最低 iOS版本 最低 OS X 版本 Notes
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:nil];
...

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

注意: 如使用最新版的sdk(>7.1.4),可自动判断上传空间。按如下方式使用:

QNConfiguration *config =[QNConfiguration   build:^(QNConfigurationBuilder *builder) {
  NSMutableArray *array = [[NSMutableArray alloc] init];
  [array addObject:[QNResolver systemResolver]];
  QNDnsManager *dns = [[QNDnsManager alloc] init:array networkInfo:[QNNetworkInfo normal]];//是否选择  https  上传
  builder.zone = [[QNAutoZone alloc] initWithHttps:YES dns:dns];//设置断点续传
  NSError *error;
  builder.recorder =  [QNFileRecorder fileRecorderWithFolder:@"保存目录" error:&error];}];

测试

所有测试

$ 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

代码贡献

详情参考 代码提交指南.

贡献记录

联系我们

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

代码许可

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

Latest podspec

{
    "name": "Qiniu",
    "version": "7.2.5",
    "summary": "Qiniu Resource Storage SDK for iOS and Mac",
    "homepage": "https://github.com/qiniu/objc-sdk",
    "social_media_url": "http://weibo.com/qiniutek",
    "authors": "Qiniu => [email protected]",
    "source": {
        "git": "https://github.com/qiniu/objc-sdk.git",
        "tag": "v7.2.5"
    },
    "platforms": {
        "ios": "7.0",
        "osx": "10.9"
    },
    "source_files": "QiniuSDK/**/*.{h,m}",
    "requires_arc": true,
    "libraries": "z",
    "dependencies": {
        "HappyDNS": [
            "~> 0.3"
        ]
    },
    "license": {
        "type": "MIT",
        "text": "The MIT License (MIT)nnCopyright (c) 2011-2017 qiniu.comnnPermission is hereby granted, free of charge, to any person obtaining a copynof this software and associated documentation files (the "Software"), to dealnin the Software without restriction, including without limitation the rightsnto use, copy, modify, merge, publish, distribute, sublicense, and/or sellncopies of the Software, and to permit persons to whom the Software isnfurnished to do so, subject to the following conditions:nnThe above copyright notice and this permission notice shall be included innall copies or substantial portions of the Software.nnTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORnIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEnAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERnLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INnTHE SOFTWARE.n"
    }
}

Pin It on Pinterest

Share This