Skip to content

Commit 0c3344a

Browse files
authored
Merge pull request #205 from longbai/multizone
multizone
2 parents ad2c730 + 3b587da commit 0c3344a

18 files changed

+505
-174
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#Changelog
22

3+
## 7.1.2 (2016-10-11)
4+
## 增加
5+
* 增加zone2
6+
37
## 7.1.1 (2016-09-08)
48
## 改变
59
* 修正 happydns 调用函数

Qiniu.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Qiniu'
3-
s.version = '7.1.1'
3+
s.version = '7.1.2'
44
s.summary = 'Qiniu Resource Storage SDK for iOS and Mac'
55
s.homepage = 'https://github.com/qiniu/objc-sdk'
66
s.social_media_url = 'http://weibo.com/qiniutek'

QiniuSDK.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101
DFF525371A626A3700D02BA1 /* QNHttpDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = DFF525361A626A3700D02BA1 /* QNHttpDelegate.h */; };
102102
DFF525391A64079B00D02BA1 /* QNSessionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF525381A64079B00D02BA1 /* QNSessionTest.m */; };
103103
DFFE0E6019E6575600D7A0FC /* QNFileRecorderTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DFFE0E5F19E6575600D7A0FC /* QNFileRecorderTest.m */; };
104+
FDEA88661DAC10D000D037E5 /* QNAutoZoneTest.m in Sources */ = {isa = PBXBuildFile; fileRef = FDEA88651DAC10D000D037E5 /* QNAutoZoneTest.m */; };
105+
FDEA88671DAC10D000D037E5 /* QNAutoZoneTest.m in Sources */ = {isa = PBXBuildFile; fileRef = FDEA88651DAC10D000D037E5 /* QNAutoZoneTest.m */; };
104106
/* End PBXBuildFile section */
105107

106108
/* Begin PBXCopyFilesBuildPhase section */
@@ -193,6 +195,7 @@
193195
DFF525361A626A3700D02BA1 /* QNHttpDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QNHttpDelegate.h; sourceTree = "<group>"; };
194196
DFF525381A64079B00D02BA1 /* QNSessionTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNSessionTest.m; sourceTree = "<group>"; };
195197
DFFE0E5F19E6575600D7A0FC /* QNFileRecorderTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNFileRecorderTest.m; sourceTree = "<group>"; };
198+
FDEA88651DAC10D000D037E5 /* QNAutoZoneTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNAutoZoneTest.m; sourceTree = "<group>"; };
196199
/* End PBXFileReference section */
197200

198201
/* Begin PBXFrameworksBuildPhase section */
@@ -378,6 +381,7 @@
378381
DFFE0E5F19E6575600D7A0FC /* QNFileRecorderTest.m */,
379382
DFF525381A64079B00D02BA1 /* QNSessionTest.m */,
380383
DF437CDE1B243A2C0099587B /* QNUpTokenTest.m */,
384+
FDEA88651DAC10D000D037E5 /* QNAutoZoneTest.m */,
381385
);
382386
path = QiniuSDKTests;
383387
sourceTree = SOURCE_ROOT;
@@ -760,6 +764,7 @@
760764
DF293C9719DB865800799011 /* QNCrc32Test.m in Sources */,
761765
DFA9B64519DFE43500A15FD1 /* QNTempFile.m in Sources */,
762766
DFF525391A64079B00D02BA1 /* QNSessionTest.m in Sources */,
767+
FDEA88661DAC10D000D037E5 /* QNAutoZoneTest.m in Sources */,
763768
DFA9B63F19DFD8C900A15FD1 /* QNEtagTest.m in Sources */,
764769
DF2CDE7119DAE90300CE01FB /* QNBase64Test.m in Sources */,
765770
);
@@ -803,6 +808,7 @@
803808
DF0A032B1B3BAC6E00E3778C /* QNEtagTest.m in Sources */,
804809
DF0A032C1B3BAC6E00E3778C /* QNTempFile.m in Sources */,
805810
DF0A032D1B3BAC6E00E3778C /* QNFileRecorderTest.m in Sources */,
811+
FDEA88671DAC10D000D037E5 /* QNAutoZoneTest.m in Sources */,
806812
DF0A032F1B3BAC6E00E3778C /* QNSessionTest.m in Sources */,
807813
DF0A03301B3BAC6E00E3778C /* QNUpTokenTest.m in Sources */,
808814
);

QiniuSDK/Common/QNVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
/**
1212
* sdk 版本
1313
*/
14-
static const NSString *kQiniuVersion = @"7.1.1";
14+
static const NSString *kQiniuVersion = @"7.1.2";

QiniuSDK/Http/QNSessionManager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
withProgressBlock:(QNInternalProgressBlock)progressBlock
3030
withCancelBlock:(QNCancelBlock)cancelBlock;
3131

32+
- (void)get:(NSString *)url
33+
withHeaders:(NSDictionary *)headers
34+
withCompleteBlock:(QNCompleteBlock)completeBlock;
35+
3236
@end
3337

3438
#endif

QiniuSDK/Http/QNSessionManager.m

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,36 @@ - (void)post:(NSString *)url
307307
});
308308
}
309309

310+
- (void)get:(NSString *)url
311+
withHeaders:(NSDictionary *)headers
312+
withCompleteBlock:(QNCompleteBlock)completeBlock {
313+
QNAsyncRun(^{
314+
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
315+
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
316+
317+
NSURL *URL = [NSURL URLWithString:url];
318+
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
319+
320+
NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
321+
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
322+
NSData* s = [@"{}" dataUsingEncoding:NSUTF8StringEncoding];
323+
NSDictionary *resp = nil;
324+
QNResponseInfo* info;
325+
if (error == nil) {
326+
info = [QNSessionManager buildResponseInfo:httpResponse withError:nil withDuration:0 withResponse:s withHost:@"" withIp:@""];
327+
if (info.isOK) {
328+
resp = responseObject;
329+
}
330+
} else {
331+
info = [QNSessionManager buildResponseInfo:httpResponse withError:error withDuration:0 withResponse:s withHost:@"" withIp:@""];
332+
}
333+
334+
completeBlock(info, resp);
335+
}];
336+
[dataTask resume];
337+
});
338+
}
339+
310340
@end
311341

312342
#endif

QiniuSDK/Http/QNUserAgent.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#import "QNUserAgent.h"
1818
#import "QNVersion.h"
1919

20-
static NSString *clientId(void) {
20+
static NSString *qn_clientId(void) {
2121
#if __IPHONE_OS_VERSION_MIN_REQUIRED
2222
NSString *s = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
2323
if (s == nil) {
@@ -31,7 +31,7 @@
3131
#endif
3232
}
3333

34-
static NSString *userAgent(NSString *id) {
34+
static NSString *qn_userAgent(NSString *id) {
3535
#if __IPHONE_OS_VERSION_MIN_REQUIRED
3636
return [NSString stringWithFormat:@"QiniuObject-C/%@ (%@; iOS %@; %@)", kQiniuVersion, [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], id];
3737
#else
@@ -51,8 +51,8 @@ - (NSString *)description {
5151

5252
- (instancetype)init {
5353
if (self = [super init]) {
54-
_id = clientId();
55-
_ua = userAgent(_id);
54+
_id = qn_clientId();
55+
_ua = qn_userAgent(_id);
5656
}
5757
return self;
5858
}

QiniuSDK/Storage/QNConfiguration.h

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ typedef NSString * (^QNUrlConvert)(NSString *url);
2727
@class QNConfigurationBuilder;
2828
@class QNDnsManager;
2929
@class QNServiceAddress;
30+
@class QNZone;
3031
/**
3132
* Builder block
3233
*
@@ -37,14 +38,9 @@ typedef void (^QNConfigurationBuilderBlock)(QNConfigurationBuilder *builder);
3738
@interface QNConfiguration : NSObject
3839

3940
/**
40-
* 默认上传服务器地址
41-
*/
42-
@property (copy, nonatomic, readonly) QNServiceAddress *up;
43-
44-
/**
45-
* 备用上传服务器地址
41+
* 存储区域
4642
*/
47-
@property (copy, nonatomic, readonly) QNServiceAddress *upBackup;
43+
@property (copy, nonatomic, readonly) QNZone *zone;
4844

4945
/**
5046
* 断点上传时的分片大小
@@ -94,29 +90,21 @@ typedef void (^QNConfigurationBuilderBlock)(QNConfigurationBuilder *builder);
9490

9591
@end
9692

93+
typedef void (^QNPrequeryReturn)(int code);
94+
95+
@class QNUpToken;
96+
9797
@interface QNZone : NSObject
9898

9999
/**
100100
* 默认上传服务器地址
101101
*/
102-
@property (nonatomic, readonly) QNServiceAddress *up;
102+
- (QNServiceAddress *)up:(QNUpToken*)token;
103103

104104
/**
105105
* 备用上传服务器地址
106106
*/
107-
@property (nonatomic, readonly) QNServiceAddress *upBackup;
108-
109-
/**
110-
* Zone初始化方法
111-
*
112-
* @param upHost 默认上传服务器地址
113-
* @param upHostBackup 备用上传服务器地址
114-
* @param upIp 备用上传IP
115-
*
116-
* @return Zone实例
117-
*/
118-
- (instancetype)initWithUp:(QNServiceAddress *)up
119-
upBackup:(QNServiceAddress *)upBackup;
107+
- (QNServiceAddress *)upBackup:(QNUpToken*)token;
120108

121109
/**
122110
* zone 0
@@ -132,6 +120,41 @@ typedef void (^QNConfigurationBuilderBlock)(QNConfigurationBuilder *builder);
132120
*/
133121
+ (instancetype)zone1;
134122

123+
/**
124+
* zone 2
125+
*
126+
* @return 实例
127+
*/
128+
+ (instancetype)zone2;
129+
130+
- (void)preQuery:(QNUpToken*)token
131+
on:(QNPrequeryReturn)ret;
132+
133+
+ (void)addIpToDns:(QNDnsManager*)dns;
134+
135+
@end
136+
137+
@interface QNFixedZone : QNZone
138+
/**
139+
* Zone初始化方法
140+
*
141+
* @param upHost 默认上传服务器地址
142+
* @param upHostBackup 备用上传服务器地址
143+
* @param upIp 备用上传IP
144+
*
145+
* @return Zone实例
146+
*/
147+
- (instancetype)initWithUp:(QNServiceAddress *)up
148+
upBackup:(QNServiceAddress *)upBackup;
149+
150+
@end
151+
152+
@interface QNAutoZone : QNZone
153+
154+
- (instancetype)initWithHttps:(BOOL)flag
155+
dns:(QNDnsManager*)dns;
156+
157+
135158
@end
136159

137160
@interface QNConfigurationBuilder : NSObject

0 commit comments

Comments
 (0)