From 25f588da631b2ba33081f68ccefa8b4f78944b4c Mon Sep 17 00:00:00 2001 From: xiesubin Date: Tue, 29 Jan 2019 17:21:03 +0800 Subject: [PATCH 1/3] fix --- ios/RNAliyunOSS+MULTIPARTUPLOAD.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ios/RNAliyunOSS+MULTIPARTUPLOAD.m b/ios/RNAliyunOSS+MULTIPARTUPLOAD.m index aff497f..cd145b1 100644 --- a/ios/RNAliyunOSS+MULTIPARTUPLOAD.m +++ b/ios/RNAliyunOSS+MULTIPARTUPLOAD.m @@ -38,7 +38,10 @@ @implementation RNAliyunOSS (MULTIPARTUPLOAD) */ RCT_REMAP_METHOD(multipartUpload, withBucketName:(NSString *)bucketName objectKey:(NSString *)objectKey uploadId:(NSString*)uploadId withFilePath:(NSString*)filePath options:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){ __block NSMutableArray * partInfos = [NSMutableArray new]; - filePath = [NSHomeDirectory() stringByAppendingPathComponent:filePath]; + if ([filePath rangeOfString:NSHomeDirectory()].location == NSNotFound) { + filePath = [NSHomeDirectory() stringByAppendingPathComponent:filePath]; + } + //分片上传数量 int chuckCount = 2; //获取文件大小 From f228955e2a6a38801b3f27a4cb3bf0fcd6d862bc Mon Sep 17 00:00:00 2001 From: xiesubin Date: Tue, 29 Jan 2019 18:06:38 +0800 Subject: [PATCH 2/3] fix --- ios/RNAliyunOSS+MULTIPARTUPLOAD.m | 1 + 1 file changed, 1 insertion(+) diff --git a/ios/RNAliyunOSS+MULTIPARTUPLOAD.m b/ios/RNAliyunOSS+MULTIPARTUPLOAD.m index cd145b1..2c131ed 100644 --- a/ios/RNAliyunOSS+MULTIPARTUPLOAD.m +++ b/ios/RNAliyunOSS+MULTIPARTUPLOAD.m @@ -41,6 +41,7 @@ @implementation RNAliyunOSS (MULTIPARTUPLOAD) if ([filePath rangeOfString:NSHomeDirectory()].location == NSNotFound) { filePath = [NSHomeDirectory() stringByAppendingPathComponent:filePath]; } + filePath = [filePath stringByReplacingOccurrencesOfString:@"file://" withString:@""]; //分片上传数量 int chuckCount = 2; From 89cfe6d0e15a6b2c9662a6d0b55c51cc803d2702 Mon Sep 17 00:00:00 2001 From: xiesubin Date: Tue, 29 Jan 2019 19:19:33 +0800 Subject: [PATCH 3/3] fix --- ios/RNAliyunOSS+MULTIPARTUPLOAD.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ios/RNAliyunOSS+MULTIPARTUPLOAD.m b/ios/RNAliyunOSS+MULTIPARTUPLOAD.m index 2c131ed..ac71a6f 100644 --- a/ios/RNAliyunOSS+MULTIPARTUPLOAD.m +++ b/ios/RNAliyunOSS+MULTIPARTUPLOAD.m @@ -62,7 +62,15 @@ @implementation RNAliyunOSS (MULTIPARTUPLOAD) uploadPart.partNumber = i; // part number start from 1 NSFileHandle* readHandle = [NSFileHandle fileHandleForReadingAtPath:filePath]; [readHandle seekToFileOffset:offset * (i -1)]; - NSData* data = [readHandle readDataOfLength:offset]; + NSData* data; + if (i == chuckCount) + { + NSUInteger lastLength = offset + fileSize % chuckCount; + data = [readHandle readDataOfLength:lastLength]; + }else + { + data = [readHandle readDataOfLength:offset]; + } uploadPart.uploadPartData = data; OSSTask * uploadPartTask = [self.client uploadPart:uploadPart]; [uploadPartTask waitUntilFinished];