开发者社区> 问答> 正文

iOS SDK的分片上传的并行上传功能不能用哦

如题,测试发现,分片上传的并行上传功能接口是返回成功的,但是根据objectKey去访问上传的图片是提示错误的,不过串行上传是没有问题的。
我的并行核心代码是这样子的:
uploadPart.uploadPartData = tempPartData;
        OSSTask * uploadPartTask = [self.ossClient uploadPart:uploadPart];
        // 并行操作
        [uploadPartTask continueWithBlock:^id _Nullable(OSSTask * _Nonnull task) {
            if (!uploadPartTask.error) {
    OSSUploadPartResult * result = uploadPartTask.result;
    uint64_t fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:uploadPart.uploadPartFileURL.absoluteString error:nil] fileSize];
    [partInfos addObject:[OSSPartInfo partInfoWithPartNum:i eTag:result.eTag size:fileSize]];
            } else {
    NSLog(@"upload part error: %@", uploadPartTask.error);
    NSLog(@"uploadObjectkey = %@", uploadObjectkey);
            }
            
            return nil;
        }];




以下是串行的核心代码:


uploadPart.uploadPartData = tempPartData;
        OSSTask * uploadPartTask = [self.ossClient uploadPart:uploadPart];
        [uploadPartTask waitUntilFinished]; ///< 串行操作
        if (!uploadPartTask.error) {
    OSSUploadPartResult * result = uploadPartTask.result;
    uint64_t fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:uploadPart.uploadPartFileURL.absoluteString error:nil] fileSize];
    [partInfos addObject:[OSSPartInfo partInfoWithPartNum:i eTag:result.eTag size:fileSize]];
        } else {
    NSLog(@"upload part error: %@", uploadPartTask.error);
    NSLog(@"uploadObjectkey = %@", uploadObjectkey);
        }





展开
收起
kobe1941 2017-08-23 17:06:31 2759 0
1 条回答
写回答
取消 提交回答
  • ReiOS SDK的分片上传的并行上传功能不能用哦
    如下图,并行上传后该图片不能访问,是我的使用姿势不对吗?

    -------------------------

    ReiOS SDK的分片上传的并行上传功能不能用哦
    问题解决了,主要是要用异步上传,不要每次都卡住线程等它上传完成,然后分片上传完成后的整合代码,要自己去实现,见下图:



    2017-08-23 18:33:02
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
从 SDK 到编解码:视频直播架构解析 立即下载
跨平台的云服务SDK需要什么 立即下载
一个跨平台的云服务SDK需要什么 立即下载