@@ -344,6 +344,7 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp
344344 if (QCloudFileExist (httpRequset.downloadingURL .path )) {
345345 httpRequset.localCacheDownloadOffset = QCloudFileSize (httpRequset.downloadingURL .path );
346346 }
347+ [httpRequset setValue: @(YES ) forKey: @" isRetry" ];
347348 [weakSelf executeRestHTTPReqeust: httpRequset];
348349 }
349350 whenError: error]) {
@@ -478,6 +479,10 @@ - (void)executeRestHTTPReqeust:(QCloudHTTPRequest *)httpRequest {
478479 NSData *data = (NSData *)body;
479480 [mutableRequest setHTTPBody: data];
480481 [mutableRequest setValue: [@([data length ]) stringValue ] forHTTPHeaderField: @" Content-Length" ];
482+ if (data.length == 0 && httpRequest.runOnService .configuration .disableUploadZeroData ){
483+ directError = [NSError qcloud_errorWithCode: QCloudNetworkErrorCodeParamterInvalid
484+ message: [NSString stringWithFormat: @" InvalidArgument:您输入的body(Data)为空并且不允许上传空文件,是否为SDK内部重试:%@ " ,httpRequest.isRetry ? @" 是" : @" 否" ]];
485+ }
481486 } else if ([body isKindOfClass: [NSURL class ]]) {
482487 NSURL *fileURL = (NSURL *)body;
483488 if (![fileURL isFileURL ]) {
@@ -487,6 +492,10 @@ - (void)executeRestHTTPReqeust:(QCloudHTTPRequest *)httpRequest {
487492 NSUInteger fileSize = QCloudFileSize (fileURL.path );
488493 [mutableRequest setValue: [@(fileSize) stringValue ] forHTTPHeaderField: @" Content-Length" ];
489494 uploadFileURL = fileURL;
495+ if (directError == nil && fileSize == 0 && httpRequest.runOnService .configuration .disableUploadZeroData ){
496+ directError = [NSError qcloud_errorWithCode: QCloudNetworkErrorCodeParamterInvalid
497+ message: [NSString stringWithFormat: @" InvalidArgument:您输入的body(NSURL:%@ )为空并且不允许上传空文件,是否为SDK内部重试:%@ " ,fileURL, httpRequest.isRetry ? @" 是" : @" 否" ]];
498+ }
490499 } else if ([body isKindOfClass: [QCloudFileOffsetBody class ]]) {
491500 QCloudFileOffsetBody *fileBody = (QCloudFileOffsetBody *)body;
492501 if (![fileBody.fileURL isFileURL ]) {
0 commit comments