Skip to content

Commit 432ac3a

Browse files
committed
Merge pull request #160 from Kivenhaoyu/master
update ios8 ipv6
2 parents 81d3788 + 7865aa7 commit 432ac3a

File tree

8 files changed

+37
-31
lines changed

8 files changed

+37
-31
lines changed

CHANGELOG.md

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

3+
## 7.0.19 (2016-05-23)
4+
5+
### 修正
6+
* iOS8 ipv6 支持
7+
38
## 7.0.18 (2016-05-10)
49

510
### 修正

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.0.18'
3+
s.version = '7.0.19’
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'

QiniuDemo/QiniuDemo/ViewController.m

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
@interface ViewController () <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
1414

1515
@property (nonatomic, strong) NSString *token;
16-
@property (nonatomic, strong) NSString *domain;
1716
@property (nonatomic, strong) UIImage *pickImage;
1817

1918
@end
@@ -40,29 +39,12 @@ - (IBAction)uploadAction:(id)sender {
4039
otherButtonTitles:nil];
4140
[alert show];
4241
} else {
43-
[self getTokenFromQN];
44-
}
45-
}
46-
47-
- (void)getTokenFromQN {
48-
//1.管理器
49-
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
50-
51-
// //2.设置登录参数
52-
// NSDictionary *dict = @{ @"username":@"xn", @"password":@"123" };
53-
54-
//3.请求
55-
[manager POST:@"http://115.231.183.102:9090/api/quick_start/simple_image_example_token.php" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
56-
self.domain = responseObject[@"domain"];
57-
self.token = responseObject[@"uptoken"];
5842
[self uploadImageToQNFilePath:[self getImagePath:self.pickImage]];
5943
}
60-
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
61-
NSLog(@"%@", error);
62-
}];
6344
}
6445

6546
- (void)uploadImageToQNFilePath:(NSString *)filePath {
47+
self.token = @"你的token";
6648
QNUploadManager *upManager = [[QNUploadManager alloc] init];
6749
QNUploadOption *uploadOption = [[QNUploadOption alloc] initWithMime:nil progressHandler:^(NSString *key, float percent) {
6850
NSLog(@"percent == %.2f", percent);
@@ -73,9 +55,6 @@ - (void)uploadImageToQNFilePath:(NSString *)filePath {
7355
[upManager putFile:filePath key:nil token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
7456
NSLog(@"info ===== %@", info);
7557
NSLog(@"resp ===== %@", resp);
76-
NSLog(@"%@/%@", self.domain, resp[@"key"]);
77-
[self.preViewImage setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", self.domain, resp[@"key"]]] placeholderImage:[UIImage imageNamed:@"placeholder.jpg"]];
78-
7958
}
8059
option:uploadOption];
8160
}

QiniuSDK/Common/QNSystem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ BOOL hasAts();
1515

1616
BOOL allowsArbitraryLoads();
1717

18+
//iOS8判断
19+
BOOL isIOS8();
20+
1821
#endif /* QNSystem_h */

QiniuSDK/Common/QNSystem.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,14 @@ BOOL allowsArbitraryLoads() {
6666
return NO;
6767
}
6868
return ats.boolValue;
69+
}
70+
71+
BOOL isIOS8() {
72+
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED)
73+
float sysVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
74+
if ((sysVersion >= 8.0) && sysVersion < 9.0) {
75+
return YES;
76+
}
77+
#endif
78+
return NO;
6979
}

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.0.18";
14+
static const NSString *kQiniuVersion = @"7.0.19";

QiniuSDK/Storage/QNConfiguration.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ - (instancetype)init {
100100
_proxy = nil;
101101
_converter = nil;
102102

103-
if (hasAts() && !allowsArbitraryLoads()) {
103+
if (hasAts() && !allowsArbitraryLoads() && isIOS8()) {
104104
_disableATS = NO;
105105
} else {
106106
_disableATS = YES;

QiniuSDKTests/QNFormUploadTest.m

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "QiniuSDK.h"
1414

1515
#import "HappyDns.h"
16+
#import "QNSystem.h"
1617
#import "QNTestConfig.h"
1718

1819
@interface QNFormUploadTest : XCTestCase
@@ -269,14 +270,18 @@ - (void)testDnsHosts {
269270
__block QNResponseInfo *testInfo = nil;
270271
__block NSDictionary *testResp = nil;
271272
__block NSString *key = nil;
273+
__block BOOL isNotiOS8 = NO;
272274
QNResolver *resolver = [[QNResolver alloc] initWithAddres:@"114.114.115.115"];
273275
QNDnsManager *dns = [[QNDnsManager alloc] init:[NSArray arrayWithObject:resolver] networkInfo:[QNNetworkInfo normal]];
274276
QNConfiguration *config = [QNConfiguration build:^(QNConfigurationBuilder *builder) {
275-
NSArray *ips = [QNZone zone0].up.ips;
276-
QNServiceAddress *s1 = [[QNServiceAddress alloc] init:@"http://uphosttest.qiniu.com" ips:ips];
277-
QNServiceAddress *s2 = [[QNServiceAddress alloc] init:@"http://uphosttestbak.qiniu.com" ips:ips];
278-
builder.zone = [[QNZone alloc] initWithUp:s1 upBackup:s2];
279-
builder.dns = dns;
277+
if (!isIOS8()) {
278+
isNotiOS8 = YES;
279+
NSArray *ips = [QNZone zone0].up.ips;
280+
QNServiceAddress *s1 = [[QNServiceAddress alloc] init:@"http://uphosttest.qiniu.com" ips:ips];
281+
QNServiceAddress *s2 = [[QNServiceAddress alloc] init:@"http://uphosttestbak.qiniu.com" ips:ips];
282+
builder.zone = [[QNZone alloc] initWithUp:s1 upBackup:s2];
283+
builder.dns = dns;
284+
}
280285
}];
281286

282287
QNUploadManager *upManager = [[QNUploadManager alloc] initWithConfiguration:config];
@@ -295,7 +300,11 @@ - (void)testDnsHosts {
295300
XCTAssert(key == nil, @"Pass");
296301
XCTAssert(testInfo.isOK, @"Pass");
297302
XCTAssert(testInfo.reqId, @"Pass");
298-
XCTAssert([testInfo.host isEqual:@"uphosttest.qiniu.com"], @"Pass");
303+
if (isNotiOS8) {
304+
XCTAssert([testInfo.host isEqual:@"uphosttest.qiniu.com"], @"Pass");
305+
} else {
306+
XCTAssert([testInfo.host isEqual:@"upload.qiniu.com"], @"Pass");
307+
}
299308
XCTAssert([@"FgoKnypncpQlV6tTVddq9EL49l4B" isEqualToString:testResp[@"key"]], @"Pass");
300309
}
301310

0 commit comments

Comments
 (0)