Skip to content

Commit 8cda798

Browse files
author
karisli
committed
# 5.6.1
- midfa \增加自定义分片大小接口 \ -budfix
1 parent 9b83721 commit 8cda798

16 files changed

+111
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 5.6.1
2+
- mta去除idfa
3+
- 增加自定义分片大小接口
4+
- budfix
5+
16
# 5.6.0
27
- 支持归档直传/-mta bugfix
38

QCloudCOSXML.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "QCloudCOSXML"
3-
s.version = "5.6.0"
3+
s.version = "5.6.1"
44
s.summary = "QCloudCOSXML 腾讯云iOS-SDK组件"
55

66
s.homepage = "https://cloud.tencent.com/"
@@ -9,12 +9,12 @@ s.version = "5.6.0"
99
s.source = { :git => "https://github.com/tencentyun/qcloud-sdk-ios.git", :tag => s.version.to_s }
1010
s.ios.deployment_target = '8.0'
1111
s.source_files = 'QCloudCOSXML/Classes/**/*'
12-
s.dependency "QCloudCore",'5.6.0'
12+
s.dependency "QCloudCore",'5.6.1'
1313
s.static_framework = true
1414

1515
s.subspec 'Transfer' do |sbt|
1616
sbt.source_files = 'QCloudCOSXML/Classes/*','QCloudCOSXML/Classes/Transfer/**/*','QCloudCOSXML/Classes/Base/*'
17-
sbt.dependency "QCloudCore",'5.6.0'
17+
sbt.dependency "QCloudCore",'5.6.1'
1818
# sbt.static_framework=true
1919
end
2020
end

QCloudCOSXML/Classes/Base/QCloudCOSXMLService+Quality.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#import "QCloudCOSXMLService+Quality.h"
99
#import <objc/runtime.h>
1010
#import <QCloudCore/MTA.h>
11+
#import <QCloudCore/MTA+Account.h>
1112
#import <QCloudCore/MTAConfig.h>
12-
#import <QCloudCore/MTACrashReporter.h>
13+
1314
#import <QCloudCore/QualityAssuranceDefine.h>
1415
#import <QCloudCore/QCloudCore.h>
1516
#import <QCloudCore/QCloudLogger.h>

QCloudCOSXML/Classes/Base/QualityDataUploader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77

88
#import <Foundation/Foundation.h>
9-
#import <QCloudCore/MTA.h>
109

1110
@interface QualityDataUploader : NSObject
1211

QCloudCOSXML/Classes/Base/QualityDataUploader.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#import "QualityDataUploader.h"
99
#import <QCloudCore/QCloudLogger.h>
1010
#import "NSError+QCloudNetworking.h"
11+
#import <QCloudCore/MTA.h>
12+
#import <QCloudCore/MTA+Account.h>
13+
#import <QCloudCore/MTAConfig.h>
1114
static NSString * kRequestSentKey = @"request_sent";
1215
static NSString * kRequestFailKey = @"request_failed";
1316
static NSString * kErrorCodeKey = @"error_code";

QCloudCOSXML/Classes/QCloudCOSXMLVersion.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
#ifndef QCloudCOSXMLModuleVersion_h
88
#define QCloudCOSXMLModuleVersion_h
9-
#define QCloudCOSXMLModuleVersionNumber 506000
9+
#define QCloudCOSXMLModuleVersionNumber 506001
1010

1111
//dependency
12-
#if QCloudCoreModuleVersionNumber != 506000
13-
#error "库QCloudCOSXML依赖QCloudCore最小版本号为5.6.0,当前引入的QCloudCore版本号过低,请及时升级后使用"
12+
#if QCloudCoreModuleVersionNumber != 506001
13+
#error "库QCloudCOSXML依赖QCloudCore最小版本号为5.6.1,当前引入的QCloudCore版本号过低,请及时升级后使用"
1414
#endif
1515

1616
//
1717
FOUNDATION_EXTERN NSString * const QCloudCOSXMLModuleVersion;
1818
FOUNDATION_EXTERN NSString * const QCloudCOSXMLModuleName;
1919

20-
#endif
20+
#endif

QCloudCOSXML/Classes/QCloudCOSXMLVersion.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#import "QCloudCOSXMLVersion.h"
2-
NSString * const QCloudCOSXMLModuleVersion = @"5.6.0";
2+
NSString * const QCloudCOSXMLModuleVersion = @"5.6.1";
33
NSString * const QCloudCOSXMLModuleName = @"QCloudCOSXML";
44
@interface QCloudQCloudCOSXMLLoad : NSObject
55
@end
@@ -26,4 +26,4 @@ + (void) load
2626
#pragma clang diagnostic pop
2727
}
2828
}
29-
@end
29+
@end

QCloudCOSXML/Classes/Transfer/request/QCloudCOSXMLUploadObjectRequest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ typedef void (^RequestsMetricArrayBlock)(NSMutableArray *requstMetricArray);
2424
如果上传的对象大小大于1MB时,我们会在内部进行分片上传的处理,将文件切分成数个1MB大小的块,然后通过并行分快上传的方式进行上传。
2525
*/
2626
@interface QCloudCOSXMLUploadObjectRequest<BodyType> : QCloudAbstractRequest
27+
@property (nonatomic,assign)NSUInteger sliceSize;
2728
/**
2829
上传文件(对象)的文件名,也是对象的key,请注意文件名中不可以含有问号即"?"字符
2930
*/

QCloudCOSXML/Classes/Transfer/request/QCloudCOSXMLUploadObjectRequest.m

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ @interface QCloudCOSXMLUploadObjectRequest ()<QCloudHttpRetryHandlerProtocol>
5151
{
5252
NSRecursiveLock* _recursiveLock;
5353
NSRecursiveLock* _progressLock;
54+
NSUInteger uploadedSize;
55+
//标记下标,从0开始
56+
NSUInteger startPartNumber;
57+
BOOL isChange;
5458
}
5559
@property (nonatomic, assign) int64_t totalBytesSent;
5660
@property (nonatomic, assign) NSUInteger dataContentLength;
5761
@property (nonatomic, strong) dispatch_source_t queueSource;
62+
//存储所有的分片
5863
@property (nonatomic, strong) NSMutableArray<QCloudMultipartInfo*>* uploadParts;
5964
@property (nonatomic, strong) NSString* uploadId;
6065
@property (nonatomic, strong) NSPointerArray* requestCacheArray;
@@ -91,6 +96,7 @@ - (instancetype) init
9196
_requstMetricArray = [NSMutableArray array];;
9297
_enableMD5Verification = YES;
9398
_retryHandler = [QCloudHTTPRetryHanlder defaultRetryHandler];
99+
startPartNumber = -1;
94100
return self;
95101
}
96102
- (NSDictionary *)modelCustomWillTransformFromDictionary:(NSDictionary *)dictionary {
@@ -134,27 +140,77 @@ - (void) continueMultiUpload:(QCloudListPartsResult*)existParts
134140
[existMap setObject:part forKey:part.partNumber];
135141
}
136142
QCloudLogDebug(@"SERVER EXIST PARTS %@", [existParts qcloud_modelToJSONString]);
137-
143+
138144
NSMutableArray* restParts = [NSMutableArray new];
139145
for (QCloudFileOffsetBody* offsetBody in allParts) {
140146
NSString* key = [@(offsetBody.index+1) stringValue];
141147
QCloudMultipartUploadPart* part = [existMap objectForKey:key];
148+
142149
if (!part) {
143150
[restParts addObject:offsetBody];
144151
} else {
152+
if (part.size != offsetBody.sliceLength) {
153+
isChange = YES;
154+
break;
155+
}
145156
QCloudMultipartInfo* info = [QCloudMultipartInfo new];
146157
info.eTag = part.eTag;
147158
info.partNumber = part.partNumber;
148159
[_uploadParts addObject:info];
149160
}
150161
}
151-
if (restParts.count == 0) {
152-
[self finishUpload:self.uploadId];
153-
} else {
154-
[self uploadOffsetBodys:restParts];
162+
163+
if (!isChange) {
164+
if (restParts.count == 0) {
165+
[self finishUpload:self.uploadId];
166+
}else{
167+
[self uploadOffsetBodys:restParts];
168+
}
169+
}else{
170+
//重新分片
171+
[self getContinueInfo:existParts.parts];
172+
if (uploadedSize == self.dataContentLength) {
173+
[self finishUpload:self.uploadId];
174+
} else {
175+
//开始分片
176+
[self uploadOffsetBodys:[self getFileLocalUploadParts]];
177+
}
178+
}
179+
}
180+
181+
-(void)getContinueInfo:(NSArray *)existParts{
182+
_uploadParts = [NSMutableArray new];
183+
int i=1;
184+
QCloudMultipartUploadPart *part = existParts[0];
185+
QCloudMultipartInfo* info = [QCloudMultipartInfo new];
186+
info.eTag = part.eTag;
187+
info.partNumber = part.partNumber;
188+
if ([info.partNumber integerValue]!=1){
189+
return;
155190
}
191+
192+
for (i = 0; i<existParts.count; i++) {
193+
QCloudMultipartUploadPart *part1 = existParts[i];
194+
QCloudMultipartInfo* info1 = [QCloudMultipartInfo new];
195+
info1.eTag = part1.eTag;
196+
info1.partNumber = part1.partNumber;
197+
uploadedSize+=part1.size;
198+
[_uploadParts addObject:info1];
199+
if (i == existParts.count-1) {
200+
break;
201+
}
202+
QCloudMultipartUploadPart *part2 = existParts[i+1];
203+
if (([part1.partNumber integerValue]+1)!= [part2.partNumber integerValue]) {
204+
break;
205+
}
206+
207+
}
208+
startPartNumber = _uploadParts.count;
209+
210+
QCloudLogDebug(@"resume startPartNumber = offset = %ld %ld",startPartNumber,uploadedSize);
156211
}
157212

213+
158214
- (void) resumeUpload
159215
{
160216
QCloudListMultipartRequest* request = [QCloudListMultipartRequest new];
@@ -179,6 +235,8 @@ - (void) resumeUpload
179235
- (void) fakeStart {
180236
[self.benchMarkMan benginWithKey:kTaskTookTime];
181237
if (self.uploadId) {
238+
startPartNumber = 0;
239+
uploadedSize = 0;
182240
[self resumeUpload];
183241
return;
184242
}
@@ -190,6 +248,9 @@ - (void) fakeStart {
190248
NSURL* url = (NSURL*)self.body;
191249
self.dataContentLength = QCloudFileSize(url.path);
192250
if (self.dataContentLength > kQCloudCOSXMLUploadLengthLimit) {
251+
//开始分片上传的时候,上传的起始位置是0
252+
uploadedSize = 0;
253+
startPartNumber = 0;
193254
[self startMultiUpload];
194255
} else {
195256
[self startSimpleUpload];
@@ -305,12 +366,14 @@ - (void) startMultiUpload {
305366
{
306367
NSMutableArray* allParts = [NSMutableArray new];
307368
NSURL* url = (NSURL*)self.body;
308-
int64_t restContentLength = self.dataContentLength;
309-
int64_t offset = 0;
310-
for (int i = 0; ;i++ ) {
369+
int64_t restContentLength = self.dataContentLength-uploadedSize;
370+
//便宜的起始位置
371+
int64_t offset = uploadedSize;
372+
for (int i = startPartNumber; ;i++ ) {
311373
int64_t slice = 0;
312-
if (restContentLength >= kQCloudCOSXMLUploadSliceLength) {
313-
slice = kQCloudCOSXMLUploadSliceLength;
374+
NSUInteger uploadSliceLength = self.sliceSize>10?self.sliceSize:kQCloudCOSXMLUploadSliceLength;
375+
if (restContentLength >= uploadSliceLength) {
376+
slice = uploadSliceLength;
314377
} else {
315378
slice = restContentLength;
316379
}

QCloudCore.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = "QCloudCore"
11-
s.version = "5.6.0"
11+
s.version = "5.6.1"
1212
s.summary = "QCloudCore--腾讯云iOS-SDK Foundation"
1313

1414
# This description is used to generate tags and improve search results.

0 commit comments

Comments
 (0)