Skip to content

Commit 4cc83eb

Browse files
committed
retry max to 0 & dns max ttl to 600s
1 parent cc1f804 commit 4cc83eb

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

QiniuDemo/QiniuDemo/ViewController.m

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ - (IBAction)uploadAction:(UIButton *)sender {
5050

5151
#ifdef YourToken
5252
NSString *path = [[NSBundle mainBundle] pathForResource:@"UploadResource.dmg" ofType:nil];
53+
path = [[NSBundle mainBundle] pathForResource:@"image.png" ofType:nil];
54+
path = [[NSBundle mainBundle] pathForResource:@"image.jpg" ofType:nil];
5355
path = [[NSBundle mainBundle] pathForResource:@"UploadResource_6M.zip" ofType:nil];
5456
// path = [[NSBundle mainBundle] pathForResource:@"UploadResource_1.44G.zip" ofType:nil];
5557

@@ -90,12 +92,13 @@ - (void)changeUploadState:(UploadState)uploadState{
9092

9193
- (void)uploadImageToQNFilePath:(NSString *)filePath {
9294

93-
kQNGlobalConfiguration.isDnsOpen = false;
95+
// kQNGlobalConfiguration.isDnsOpen = false;
96+
9497

9598
NSString *key = [NSString stringWithFormat:@"iOS_Demo_%@", [NSDate date]];
9699
self.token = YourToken;
97100
QNConfiguration *configuration = [QNConfiguration build:^(QNConfigurationBuilder *builder) {
98-
builder.useConcurrentResumeUpload = NO;
101+
builder.useConcurrentResumeUpload = true;
99102
builder.resumeUploadVersion = QNResumeUploadVersionV2;
100103
builder.recorder = [QNFileRecorder fileRecorderWithFolder:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] error:nil];
101104
}];
@@ -121,27 +124,27 @@ - (void)uploadImageToQNFilePath:(NSString *)filePath {
121124
// }
122125
// option:uploadOption];
123126

124-
// long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil] fileSize];
125-
// NSInputStream *stream = [NSInputStream inputStreamWithFileAtPath:filePath];
126-
// [upManager putInputStream:stream sourceId:filePath.lastPathComponent size:fileSize fileName:filePath.lastPathComponent key:key token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
127-
// NSLog(@"info ===== %@", info);
128-
// NSLog(@"resp ===== %@", resp);
129-
//
130-
// [weakSelf changeUploadState:UploadStatePrepare];
131-
// [weakSelf alertMessage:info.message];
132-
// } option:uploadOption];
133-
134-
// NSURL *url = [NSURL fileURLWithPath:filePath];
135-
// PHFetchResult *fetchResult = [PHAsset fetchAssetsWithALAssetURLs:@[url] options:nil];
136-
PHAsset *asset = [self getPHAssert];
137-
[upManager putPHAsset:asset key:key token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
127+
long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil] fileSize];
128+
NSInputStream *stream = [NSInputStream inputStreamWithFileAtPath:filePath];
129+
[upManager putInputStream:stream sourceId:filePath.lastPathComponent size:fileSize fileName:filePath.lastPathComponent key:key token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
138130
NSLog(@"info ===== %@", info);
139131
NSLog(@"resp ===== %@", resp);
140132

141133
[weakSelf changeUploadState:UploadStatePrepare];
142134
[weakSelf alertMessage:info.message];
143-
}
144-
option:uploadOption];
135+
} option:uploadOption];
136+
137+
// NSURL *url = [NSURL fileURLWithPath:filePath];
138+
// PHFetchResult *fetchResult = [PHAsset fetchAssetsWithALAssetURLs:@[url] options:nil];
139+
// PHAsset *asset = [self getPHAssert];
140+
// [upManager putPHAsset:asset key:key token:self.token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
141+
// NSLog(@"info ===== %@", info);
142+
// NSLog(@"resp ===== %@", resp);
143+
//
144+
// [weakSelf changeUploadState:UploadStatePrepare];
145+
// [weakSelf alertMessage:info.message];
146+
// }
147+
// option:uploadOption];
145148
}
146149

147150
- (PHAsset *)getPHAssert {

QiniuSDK/Storage/QNConfiguration.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ - (void)setupData{
8787
_dnsCacheDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches/Dns"];
8888
_dnsRepreHostNum = 2;
8989
_dnsCacheTime = kQNDefaultDnsCacheTime;
90-
_dnsCacheMaxTTL = 30*60;
90+
_dnsCacheMaxTTL = 10*60;
9191

9292
_globalHostFrozenTime = 10;
9393
_partialHostFrozenTime = 5*60;
@@ -106,7 +106,7 @@ - (instancetype)init {
106106
_zone = [[QNAutoZone alloc] init];
107107
_chunkSize = 2 * 1024 * 1024;
108108
_putThreshold = 4 * 1024 * 1024;
109-
_retryMax = 1;
109+
_retryMax = 0;
110110
_timeoutInterval = 90;
111111
_retryInterval = 0.5;
112112

0 commit comments

Comments
 (0)