From f7c166bede9bc4d63712cd27f79a623a7f002ace Mon Sep 17 00:00:00 2001 From: Hugh Lv Date: Tue, 15 Jan 2013 13:45:27 +0800 Subject: [PATCH 1/5] Added X-Log in errorInfo. --- QiniuSDK/QiniuSimpleUploader.m | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/QiniuSDK/QiniuSimpleUploader.m b/QiniuSDK/QiniuSimpleUploader.m index 557673f..bd135fa 100644 --- a/QiniuSDK/QiniuSimpleUploader.m +++ b/QiniuSDK/QiniuSimpleUploader.m @@ -16,6 +16,8 @@ #define kFilePathKey @"filePath" #define kHashKey @"hash" #define kErrorKey @"error" +#define kXlogKey @"X-Log" +#define kXreqidKey @"X-Reqid" #define kFileSizeKey @"fileSize" #define kKeyKey @"key" #define kBucketKey @"bucket" @@ -271,9 +273,26 @@ - (void) reportFailure:(ASIHTTPRequest *)request errorDescription = [httpError localizedDescription]; } - NSDictionary *userInfo = nil; + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; if (errorDescription) { - userInfo = [NSDictionary dictionaryWithObject:errorDescription forKey:kErrorKey]; + [userInfo setObject:errorDescription forKey:kErrorKey]; + } + + NSDictionary *respHeaders = [request responseHeaders]; + if (respHeaders) { + // TEST ONLY CODE. + //for (id key in [respHeaders allKeys]) { + // NSLog(@"HEADER[%@]:%@", key, [respHeaders objectForKey:key]); + //} + + NSObject *xlogObj = [respHeaders objectForKey:kXlogKey]; + if (xlogObj) { + [userInfo setObject:xlogObj forKey:kXlogKey]; + } + NSObject *xreqidObj = [respHeaders objectForKey:kXreqidKey]; + if (xreqidObj) { + [userInfo setObject:xreqidObj forKey:kXreqidKey]; + } } NSError *error = [NSError errorWithDomain:kErrorDomain code:errorCode userInfo:userInfo]; From 9c4f6c42db041401f023f75497039bbe9a8179f0 Mon Sep 17 00:00:00 2001 From: Hugh Lv Date: Tue, 15 Jan 2013 13:45:27 +0800 Subject: [PATCH 2/5] Added X-Log in errorInfo. --- QiniuSDK/QiniuSimpleUploader.m | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/QiniuSDK/QiniuSimpleUploader.m b/QiniuSDK/QiniuSimpleUploader.m index 557673f..b7cec35 100644 --- a/QiniuSDK/QiniuSimpleUploader.m +++ b/QiniuSDK/QiniuSimpleUploader.m @@ -16,6 +16,8 @@ #define kFilePathKey @"filePath" #define kHashKey @"hash" #define kErrorKey @"error" +#define kXlogKey @"X-Log" +#define kXreqidKey @"X-Reqid" #define kFileSizeKey @"fileSize" #define kKeyKey @"key" #define kBucketKey @"bucket" @@ -263,7 +265,7 @@ - (void) reportFailure:(ASIHTTPRequest *)request if (dic) { // Check if there is response content. NSObject *errorObj = [dic objectForKey:kErrorKey]; if (errorObj) { - errorDescription = [(NSString *)errorObj copy]; + errorDescription = (NSString *)errorObj; } } if (errorDescription == nil && httpError) { // No response, then try to retrieve the HTTP error info. @@ -271,9 +273,26 @@ - (void) reportFailure:(ASIHTTPRequest *)request errorDescription = [httpError localizedDescription]; } - NSDictionary *userInfo = nil; + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; if (errorDescription) { - userInfo = [NSDictionary dictionaryWithObject:errorDescription forKey:kErrorKey]; + [userInfo setObject:errorDescription forKey:kErrorKey]; + } + + NSDictionary *respHeaders = [request responseHeaders]; + if (respHeaders) { + // TEST ONLY CODE. + //for (id key in [respHeaders allKeys]) { + // NSLog(@"HEADER[%@]:%@", key, [respHeaders objectForKey:key]); + //} + + NSObject *xlogObj = [respHeaders objectForKey:kXlogKey]; + if (xlogObj) { + [userInfo setObject:xlogObj forKey:kXlogKey]; + } + NSObject *xreqidObj = [respHeaders objectForKey:kXreqidKey]; + if (xreqidObj) { + [userInfo setObject:xreqidObj forKey:kXreqidKey]; + } } NSError *error = [NSError errorWithDomain:kErrorDomain code:errorCode userInfo:userInfo]; From 5f41ae9530b14a788d9d5c268b33bdb954d6a2ed Mon Sep 17 00:00:00 2001 From: 404 Date: Fri, 1 Feb 2013 18:22:50 +0800 Subject: [PATCH 3/5] updated README --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e7c152..43e7369 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ title: iOS SDK | 七牛云存储 # iOS SDK -SDK下载地址:[https://github.com/qiniu/ios-sdk](https://github.com/qiniu/ios-sdk) +- iOS SDK 源码地址: +- iOS SDK 下载地址: 本SDK目前只提供了一个简单版本的上传功能,在类QiniuSimpleUploader中实现。 @@ -113,3 +114,23 @@ extraParams是一个NSDictionary类型,upload方法会检查该字典中是否 如果以静态链接库的方式使用该SDK,请注意您的工程设置中需要设置-ObjC标志,这是因为该SDK中使用了Objective-C category功能来实现JSON字符串的序列化和反序列化,而没有-ObjC标志的话Objective-C category功能将不能正常工作,错误表现为直接异常退出。 另外,由于QiniuSimpleUploader采用的是单次HTTP请求发送整个文件内容的方法,因此并不适合用于上传大尺寸的文件。如果您有这方面的需求,请[联系我们](https://dev.qiniutek.com/feedback)。我们稍后也会在SDK中增加支持断点续传的上传类。 + + + + +## 贡献代码 + +七牛云存储 iOS SDK 源码地址: + +1. 登录 [github.com](https://github.com) +2. Fork +3. 创建您的特性分支 (`git checkout -b my-new-feature`) +4. 提交您的改动 (`git commit -am 'Added some feature'`) +5. 将您的改动记录提交到远程 `git` 仓库 (`git push origin my-new-feature`) +6. 然后到 github 网站的该 `git` 远程仓库的 `my-new-feature` 分支下发起 Pull Request + + + +## 许可证 + +Copyright (c) 2012-2013 qiniutek.com \ No newline at end of file From f571bfe146a3526426bb83ff154bbaaaff87db9b Mon Sep 17 00:00:00 2001 From: xushiwei Date: Wed, 6 Feb 2013 18:11:33 +0800 Subject: [PATCH 4/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 43e7369..f5b9f99 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ title: iOS SDK | 七牛云存储 # iOS SDK -- iOS SDK 源码地址: - iOS SDK 下载地址: +- iOS SDK 源码地址: (请注意非 master 分支的代码在规格上可能承受变更) 本SDK目前只提供了一个简单版本的上传功能,在类QiniuSimpleUploader中实现。 @@ -133,4 +133,4 @@ extraParams是一个NSDictionary类型,upload方法会检查该字典中是否 ## 许可证 -Copyright (c) 2012-2013 qiniutek.com \ No newline at end of file +Copyright (c) 2012-2013 qiniutek.com From 587acf64bb09f8372c68b77ce787b9b912e14fa0 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Fri, 28 Jun 2013 13:16:47 +0800 Subject: [PATCH 5/5] CHANGELOG --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a1ec1ca --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +## CHANGE LOG + +### v3.3.0 + +2013-06-28 issue [#14](https://github.com/qiniu/ios-sdk/pull/14) + +- error 类型增加 `X-Log`, `X-Reqid`。 +