iOS七牛上传获取的进度一直是1.0

新手上路,请多包涵

七牛上传图片,获取进度只有一次1.00。

  1. 上传时设置的代码

- (void)putData:(NSData *)filedata key:(NSString *)key progressHandler:(QNUpProgressHandler)progress complete:(QNUpCompletionHandler)completionHandler
{
    
    if (![self chechoutToken]) {
        [self getTokenWith:_param];
        return;
    }
    
    QNUploadOption *opt = [[QNUploadOption alloc] initWithMime:@"image/jpeg"
                                               progressHandler:progress
                                                        params:nil
                                                      checkCrc:false
                                            cancellationSignal:nil];
    
    QNConfiguration *config = [QNConfiguration build:^(QNConfigurationBuilder *builder) {
        NSMutableArray *array = [[NSMutableArray alloc] init];
        [array addObject:[QNResolver systemResolver]];
        QNDnsManager *dns = [[QNDnsManager alloc] init:array networkInfo:[QNNetworkInfo normal]];
        //是否选择  https  上传
        builder.zone = [[QNAutoZone alloc] initWithHttps:YES dns:dns];
        //设置断点续传
        NSError *error;
        builder.recorder = [QNFileRecorder fileRecorderWithFolder:@"保存目录" error:&error];
    }];
    
    QNUploadManager *upManager = [[QNUploadManager alloc] initWithConfiguration:config];
    [upManager putData:filedata key:key token:_token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
        if (completionHandler) {
            completionHandler(info, key, resp);
        }
    } option:opt];
}

执行时的代码

__weak typeof(self)weakself = self;
    [[EHQiNiuManager shareInstance] putData:data key:[NSString createFileNameWithPre:@"feedback"] progressHandler:^(NSString *key, float percent) {
        NSLog(@"%@: %.2f", key, percent);
        [UIView animateWithDuration:0.1 animations:^{
            weakself.coverView.frame = CGRectMake(0, 0, weakself.bounds.size.width, weakself.bounds.size.height * (1 - percent));
        }];
    } complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
        if (resp == nil) {
            // 上传失败
            NSLogErrorLogin(@"上传失败:%@", info.error);
        } else {
            weakself.imageName = resp[@"key"];
        }
    }];
阅读 3.4k
1 个回答

您好,上传的如果是小于4M的文件,不会启用分片上传,所以上传成功后返回进度1

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
七牛云问答
子站问答
访问
宣传栏