开发者社区> 问答> 正文

iOS uploadProgress 进度回调block不走

put.uploadProgress = ^(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend) {

        // 当前上传段长度、当前已经上传总长度、一共需要上传的总长度
        NSLog(@"====== %lld, %lld, %lld", bytesSent, totalByteSent, totalBytesExpectedToSend);
    }; 

这个函数没有回调,是什么问题 最新的framework

展开
收起
王衍超 2016-12-07 10:27:45 4811 0
1 条回答
写回答
取消 提交回答
  • 有人 回答么?


    id<OSSCredentialProvider> credential = [[OSSFederationCredentialProvider alloc] initWithFederationTokenGetter:^OSSFederationToken *{
        OSSFederationToken * token = [OSSFederationToken new];
        token.tAccessKey = accessKey;
        token.tSecretKey = secretKey;
        token.tToken = tToken;
        return token;
    }];
    OSSClientConfiguration * conf = [OSSClientConfiguration new];
    conf.maxRetryCount = 2;
    conf.timeoutIntervalForRequest = 30;
    self.client = [[OSSClient alloc] initWithEndpoint:ENDPOINT credentialProvider:credential clientConfiguration:conf];
    
    OSSPutObjectRequest * put = [OSSPutObjectRequest new];
    // 必填字段
    put.bucketName = bucketName;
    put.objectKey = key;
    put.uploadingData = data;
    if (option) {
        put.uploadProgress = ^(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend) {
            // 当前上传段长度、当前已经上传总长度、一共需要上传的总长度
        这里怎么不走
    
        };
    }
    if (option.callbackParam) {
        put.callbackParam = option.callbackParam;
    }
    if (option.params) {
        put.callbackVar = option.params;
    }
    
    OSSTask * putTask = [self.client putObject:put];
    [putTask continueWithBlock:^id(OSSTask *task) {
        if (!task.error) {
            NSLog(@"upload object success!");
        } else {
            NSLog(@"upload object failed, error: %@" , task.error);
        }
        return nil;
    }];
    

    有人解决么

    2019-07-17 20:31:55
    赞同 1 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载