您的位置:首页 > 其它

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

2016-10-21 15:11 211 查看
#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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: