@@ -67,7 +67,7 @@ @interface QCloudCOSXMLUploadObjectRequest () <QCloudHttpRetryHandlerProtocol> {
6767@implementation QCloudCOSXMLUploadObjectRequest
6868
6969- (void )dealloc {
70- NSLog (@" QCloudCOSXMLUploadObjectRequest = %@ dealloc" , self);
70+ QCloudLogInfo (@" QCloudCOSXMLUploadObjectRequest = %@ dealloc" , self);
7171 if (NULL != _queueSource) {
7272 dispatch_source_cancel (_queueSource);
7373 }
@@ -90,13 +90,14 @@ - (instancetype)init {
9090 _recursiveLock = [NSRecursiveLock new ];
9191 _progressLock = [NSRecursiveLock new ];
9292 _requstMetricArray = [NSMutableArray array ];
93- ;
93+ _mutilThreshold = kQCloudCOSXMLUploadLengthLimit ;
9494 _enableMD5Verification = YES ;
9595 _retryHandler = [QCloudHTTPRetryHanlder defaultRetryHandler ];
9696 startPartNumber = -1 ;
9797 self.priority = QCloudAbstractRequestPriorityHigh;
9898 return self;
9999}
100+
100101- (NSDictionary *)modelCustomWillTransformFromDictionary : (NSDictionary *)dictionary {
101102 NSMutableDictionary *dict = [dictionary mutableCopy ];
102103 if ([dictionary valueForKey: @" body" ]) {
@@ -249,7 +250,15 @@ - (void)fakeStart {
249250 return ;
250251 }
251252 self.dataContentLength = QCloudFileSize (url.path );
252- if (self.dataContentLength > kQCloudCOSXMLUploadLengthLimit ) {
253+ if (_mutilThreshold<kQCloudCOSXMLUploadLengthLimit ){
254+ @throw [NSException
255+ exceptionWithName: QCloudErrorDomain
256+ reason: [NSString
257+ stringWithFormat:
258+ @" 分块接口的阈值不能小于 1MB ,当前阈值为 %ld " , (long )_mutilThreshold]
259+ userInfo: nil ];
260+ }
261+ if (self.dataContentLength > _mutilThreshold) {
253262 // 开始分片上传的时候,上传的起始位置是0
254263 uploadedSize = 0 ;
255264 startPartNumber = 0 ;
@@ -277,8 +286,10 @@ - (void)startSimpleUpload {
277286 request.finishBlock = ^(id outputObject, NSError *error) {
278287 __strong typeof (weakSelf) strongSelf = weakSelf;
279288 __strong typeof (weakRequest) strongRequst = weakRequest;
280- [strongSelf.requstMetricArray addObject: @{ [NSString stringWithFormat: @" %@ " , strongRequst] : weakRequest.benchMarkMan .tastMetrics }];
281-
289+ [weakSelf.requstMetricArray addObject: @{ [NSString stringWithFormat: @" %@ " , strongRequst] : weakRequest.benchMarkMan .tastMetrics }];
290+ if (self.requstsMetricArrayBlock ) {
291+ self.requstsMetricArrayBlock (weakSelf.requstMetricArray );
292+ }
282293 if (error) {
283294 [weakSelf onError: error];
284295 [self cancel ];
@@ -564,7 +575,6 @@ - (void)onError:(NSError *)error {
564575- (void )finishUpload : (NSString *)uploadId {
565576 NSURL *url = (NSURL *)self.body ;
566577 if (self.canceled ){
567- NSLog (@" finishUpload canceled = %d " ,self.canceled ?1 :0 );
568578 return ;
569579 }
570580 if (!self.uploadBodyIsCompleted ){
@@ -680,7 +690,7 @@ - (QCloudCOSXMLUploadObjectResumeData)cancelByProductingResumeData:(NSError *__a
680690}
681691
682692- (QCloudCOSXMLUploadObjectResumeData)productingReqsumeData : (NSError *__autoreleasing *)error {
683- if (_dataContentLength <= kQCloudCOSXMLUploadLengthLimit ) {
693+ if (_dataContentLength <= _mutilThreshold ) {
684694 if (NULL != error) {
685695 *error = [NSError qcloud_errorWithCode: QCloudNetworkErrorUnsupportOperationError
686696 message: @" UnsupportOperation:无法暂停当前的上传请求,因为使用的是单次上传" ];
0 commit comments