七牛云视频上传方法 上传进度 断点续传

来源:互联网 发布:淘宝网舞蹈演出服装 编辑:程序博客网 时间:2024/05/23 15:15

#import <QiniuSDK.h>一。七牛云视频上传的两种方法 方法1. 文件地址上传 已知视频在本地的地址 fileUrl[_upManager putFile:fileUrl key:nil token:uptoken complete: ^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {      NSLog(@"看看-------%@",info);      NSLog(@"看看-------%@",resp);  } option:opt];  方法2. 将视频转为data上传  [_upManager putData:fileData key:nil token:uptoken complete: ^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {      NSLog(@"看看-------%@",info);      NSLog(@"看看-------%@",resp);      //                          [self sysData:resp andSynData:synData ];  } option:opt];  二。带上传进度的上传方法#import <QiniuSDK.h>#import <Qiniu/QNUploadOption.h> // 上传进度代理方法        QNUploadOption * uploadOption = [[QNUploadOption alloc] initWithProgressHandler:^(NSString *key, float percent) {// percent 为上传进度        }];[_upManager putFile:fileUrl key:nil token:uptoken complete: ^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {      NSLog(@"看看-------%@",info);      NSLog(@"看看-------%@",resp);  } option:uploadOption];三。带上传进度 断点续传的上传方法#import <QiniuSDK.h>#import <Qiniu/QNUploadOption.h>// 上传进度代理方法        QNUploadOption * uploadOption = [[QNUploadOption alloc] initWithProgressHandler:^(NSString *key, float percent) {// percent 为上传进度forKey:videoName];        }];//文件管理  文件路径可以自定义        NSString *document = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];        //upprogress 文件夹用来存储上传进度 七牛云自动实现记录 无需别的操作        NSString* fileurl = [document stringByAppendingPathComponent:@"upprogress"];        // 传入断点记录的代理        QNFileRecorder *file = [QNFileRecorder fileRecorderWithFolder:fileurl error:nil];        // 创建带有断点记录代理的上传管理者        QNUploadManager *upManager = [[QNUploadManager alloc] initWithRecorder:file];             if (token) {            // 以文件形式上传==========断点续传的话只能使用文件上传            [upManager putFile:videoUrl key:videoName token:token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {                NSLog(@"看看-------%@",info);                NSLog(@"看看-------%@",resp);                    } option:uploadOption];


0 0
原创粉丝点击