Skip to content

Commit a34b47f

Browse files
committed
Merge pull request #15 from longbai/comment
增加注释
2 parents a762177 + bcec1ce commit a34b47f

File tree

13 files changed

+336
-3
lines changed

13 files changed

+336
-3
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: objective-c
22
before_install:
3-
- brew update
4-
- brew upgrade xctool
3+
# - brew update
4+
# - brew upgrade xctool
55
- gem install cocoapods
66
before_script:
77
- export QINIU_TEST_ENV="travis"

QiniuSDK.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
DF0D23CC19DCE6C400D6B68F /* QNResponseInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QNResponseInfo.h; sourceTree = "<group>"; };
125125
DF0D23CE19DCE6E500D6B68F /* QNResponseInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNResponseInfo.m; sourceTree = "<group>"; };
126126
DF293C9019DB85CB00799011 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
127-
DF293C9319DB860200799011 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; };
127+
DF293C9319DB860200799011 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; };
128128
DF293C9619DB865800799011 /* QNCrc32Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNCrc32Test.m; sourceTree = "<group>"; };
129129
DF293C9C19DBC2AE00799011 /* QNUserAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QNUserAgent.h; sourceTree = "<group>"; };
130130
DF293C9D19DBC2AE00799011 /* QNUserAgent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNUserAgent.m; sourceTree = "<group>"; };

QiniuSDK/Common/QNConfig.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,37 @@
88

99
#import <Foundation/Foundation.h>
1010

11+
/**
12+
* 默认上传服务器
13+
*/
1114
extern NSString *const kQNUpHost;
1215

16+
/**
17+
* 备用上传服务器,当默认服务器网络连接失败时使用
18+
*/
1319
extern NSString *const kQNUpHostBackup;
1420

21+
/**
22+
* 断点上传时的分片大小
23+
*/
1524
extern const UInt32 kQNChunkSize;
1625

26+
/**
27+
* 断点上传时的分块大小
28+
*/
1729
extern const UInt32 kQNBlockSize;
1830

31+
/**
32+
* 上传失败的重试次数
33+
*/
1934
extern const UInt32 kQNRetryMax;
2035

36+
/**
37+
* 如果大于此值就使用断点上传,否则使用form上传
38+
*/
2139
extern const UInt32 kQNPutThreshold;
2240

41+
/**
42+
* 超时时间
43+
*/
2344
extern const float kQNTimeoutInterval;

QiniuSDK/Common/QNCrc32.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,29 @@
88

99
#import <Foundation/Foundation.h>
1010

11+
/**
12+
* 生成crc32 校验码
13+
*/
1114
@interface QNCrc32 : NSObject
1215

16+
/**
17+
* 文件校验
18+
*
19+
* @param filePath 文件路径
20+
* @param error 文件读取错误
21+
*
22+
* @return 校验码
23+
*/
1324
+ (UInt32)file:(NSString *)filePath
1425
error:(NSError **)error;
26+
27+
/**
28+
* 二进制字节校验
29+
*
30+
* @param data 二进制数据
31+
*
32+
* @return 校验码
33+
*/
1534
+ (UInt32)data:(NSData *)data;
1635

1736
@end

QiniuSDK/Common/QNEtag.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,28 @@
88

99
#import <Foundation/Foundation.h>
1010

11+
/**
12+
* 服务器 hash etag 生成
13+
*/
1114
@interface QNEtag : NSObject
15+
16+
/**
17+
* 文件etag
18+
*
19+
* @param filePath 文件路径
20+
* @param error 输出文件读取错误
21+
*
22+
* @return etag
23+
*/
1224
+ (NSString *)file:(NSString *)filePath
1325
error:(NSError **)error;
26+
27+
/**
28+
* 二进制数据etag
29+
*
30+
* @param data 数据
31+
*
32+
* @return etag
33+
*/
1434
+ (NSString *)data:(NSData *)data;
1535
@end

QiniuSDK/Common/QNUrlSafeBase64.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,27 @@
77

88
#import <Foundation/Foundation.h>
99

10+
/**
11+
* url safe base64 编码类, 对/ 做了处理
12+
*/
1013
@interface QNUrlSafeBase64 : NSObject
1114

15+
/**
16+
* 字符串编码
17+
*
18+
* @param source 字符串
19+
*
20+
* @return base64 字符串
21+
*/
1222
+ (NSString *)encodeString:(NSString *)source;
1323

24+
/**
25+
* 二进制数据编码
26+
*
27+
* @param source 二进制数据
28+
*
29+
* @return base64字符串
30+
*/
1431
+ (NSString *)encodeData:(NSData *)source;
1532

1633
@end

QiniuSDK/Common/QNVersion.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88

99
#import <Foundation/Foundation.h>
1010

11+
/**
12+
* sdk 版本
13+
*/
1114
static const NSString *kQiniuVersion = @"7.0.6";

QiniuSDK/Http/QNResponseInfo.h

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,115 @@
88

99
#import <Foundation/Foundation.h>
1010

11+
/**
12+
* 中途取消的状态码
13+
*/
1114
extern const int kQNRequestCancelled;
15+
16+
/**
17+
* 网络错误状态码
18+
*/
1219
extern const int kQNNetworkError;
20+
21+
/**
22+
* 错误参数状态码
23+
*/
1324
extern const int kQNInvalidArgument;
25+
26+
/**
27+
* 读取文件错误状态码
28+
*/
1429
extern const int kQNFileError;
1530

31+
/**
32+
* 上传完成后返回的状态信息
33+
*/
1634
@interface QNResponseInfo : NSObject
1735

36+
/**
37+
* 状态码
38+
*/
1839
@property (readonly) int statusCode;
40+
41+
/**
42+
* 七牛服务器生成的请求ID,用来跟踪请求信息,如果使用过程中出现问题,请反馈此ID
43+
*/
1944
@property (nonatomic, copy, readonly) NSString *reqId;
45+
46+
/**
47+
* 七牛服务器内部跟踪记录
48+
*/
2049
@property (nonatomic, copy, readonly) NSString *xlog;
50+
51+
/**
52+
* 错误信息,出错时请反馈此记录
53+
*/
2154
@property (nonatomic, copy, readonly) NSError *error;
55+
56+
/**
57+
* 是否取消
58+
*/
2259
@property (nonatomic, readonly, getter = isCancelled) BOOL canceled;
60+
61+
/**
62+
* 成功的请求
63+
*/
2364
@property (nonatomic, readonly, getter = isOK) BOOL ok;
65+
66+
/**
67+
* 是否网络错误
68+
*/
2469
@property (nonatomic, readonly, getter = isConnectionBroken) BOOL broken;
70+
71+
/**
72+
* 是否需要重试,内部使用
73+
*/
2574
@property (nonatomic, readonly) BOOL couldRetry;
2675

76+
/**
77+
* 工厂函数,内部使用
78+
*
79+
* @return 取消的实例
80+
*/
2781
+ (instancetype)cancel;
2882

83+
/**
84+
* 工厂函数,内部使用
85+
*
86+
* @param desc 错误参数描述
87+
*
88+
* @return 错误参数实例
89+
*/
2990
+ (instancetype)responseInfoWithInvalidArgument:(NSString *)desc;
3091

92+
/**
93+
* 工厂函数,内部使用
94+
*
95+
* @param error 错误信息
96+
*
97+
* @return 网络错误实例
98+
*/
3199
+ (instancetype)responseInfoWithNetError:(NSError *)error;
32100

101+
/**
102+
* 工厂函数,内部使用
103+
*
104+
* @param error 错误信息
105+
*
106+
* @return 文件错误实例
107+
*/
33108
+ (instancetype)responseInfoWithFileError:(NSError *)error;
34109

110+
/**
111+
* 构造函数
112+
*
113+
* @param status 状态码
114+
* @param reqId 七牛服务器请求id
115+
* @param xlog 七牛服务器记录
116+
* @param body 服务器返回内容
117+
*
118+
* @return 实例
119+
*/
35120
- (instancetype)init:(int)status
36121
withReqId:(NSString *)reqId
37122
withXLog:(NSString *)xlog

QiniuSDK/Http/QNUserAgent.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@
88

99
#import <Foundation/Foundation.h>
1010

11+
/**
12+
* UserAgent 生成函数
13+
*
14+
* @return UserAgent 字串
15+
*/
1116
NSString *QNUserAgent(void);

QiniuSDK/Recorder/QNFileRecorder.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,42 @@
99
#import <Foundation/Foundation.h>
1010
#import "QNRecorderDelegate.h"
1111

12+
/**
13+
* 将上传记录保存到文件系统中
14+
*/
1215
@interface QNFileRecorder : NSObject <QNRecorderDelegate>
1316

17+
/**
18+
* 用指定保存的目录进行初始化
19+
*
20+
* @param directory 目录
21+
* @param error 输出的错误信息
22+
*
23+
* @return 实例
24+
*/
1425
+ (instancetype)fileRecorderWithFolder:(NSString *)directory
1526
error:(NSError *__autoreleasing *)error;
1627

28+
/**
29+
* 用指定保存的目录,以及是否进行base64编码进行初始化,
30+
*
31+
* @param directory 目录
32+
* @param encode 为避免因为特殊字符或含有/,无法保存持久化记录,故用此参数指定是否要base64编码
33+
* @param error 输出错误信息
34+
*
35+
* @return 实例
36+
*/
1737
+ (instancetype)fileRecorderWithFolder:(NSString *)directory
1838
encodeKey:(BOOL)encode
1939
error:(NSError *__autoreleasing *)error;
2040

41+
/**
42+
* 从外部手动删除记录,如无特殊需求,不建议使用
43+
*
44+
* @param key 持久化记录key
45+
* @param dir 目录
46+
* @param encode 是否encode
47+
*/
2148
+ (void)removeKey:(NSString *)key
2249
directory:(NSString *)dir
2350
encodeKey:(BOOL)encode;

0 commit comments

Comments
 (0)