七牛------iOS多文件上传demo
来源:互联网 发布:修改淘宝评价的链接 编辑:程序博客网 时间:2024/06/13 00:20
**//选择上传的内容,放到数组中**NSString *file1 = [[[NSBundle mainBundle]pathForResource:@"picture" ofType:@"bundle"] stringByAppendingPathComponent:@"0b11711cf955d77e44764558e3ef235e.png"];NSString *file2 = [[[NSBundle mainBundle]pathForResource:@"picture" ofType:@"bundle"] stringByAppendingPathComponent:@"0b11711cf955d77e44764558e3ef235e.png"];NSString *file3 = [[[NSBundle mainBundle]pathForResource:@"picture" ofType:@"bundle"] stringByAppendingPathComponent:@"0b11711cf955d77e44764558e3ef235e.png"];NSArray *ary = @[file1,file2,file3];**//该链接公网不可访问**AFHTTPRequestOperationManager *manger = [AFHTTPRequestOperationManager manager];NSString *url = @"http://zhanghan/qiniu/examples/up.php";manger.responseSerializer = [AFHTTPResponseSerializer serializer];[manger GET:url parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) { **//获取token** NSString *token = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]; QNUploadManager *manager = [[QNUploadManager alloc]init]; **//开启异步线程上传图片** dispatch_async(dispatch_get_global_queue(0, 0), ^{ for (int i = 0; i < ary.count; i++) { **//图片转为data类型** UIImage *image = [UIImage imageNamed:[ary objectAtIndex:i]]; NSData *data = UIImageJPEGRepresentation(image, 0); **//上传** [manager putData:data key:nil token:token complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) { if (info.statusCode == 200) { NSLog(@"上传成功"); NSLog(@"%@",resp); }else { NSLog(@"上传失败"); NSLog(@"%@",info); } } option:nil]; } });} failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) { **//失败** NSLog(@"%@",error);}];
}
0 0
- 七牛------iOS多文件上传demo
- 七牛文件上传
- 七牛上传文件
- IOS七牛上传图片
- 七牛上传文件 图片
- 七牛---Android SDK断点续传与暂停上传Demo
- 七牛---Android SDK断点续传与暂停上传Demo
- 多文件上传 iOS
- SWFUpload实现多文件上传DEMO
- MultipartHttpServletRequest 多文件上传。个人demo
- SpringMVC上传文件demo
- PHP 文件上传Demo
- FTP文件上传demo
- fileupload文件上传demo
- AFNetWorking 文件上传Demo
- ajax 上传文件 demo
- struts文件上传demo
- FTP上传文件demo
- 蓝桥杯往届试题---切面条(递归)
- keystone的兼容API
- Android中View的绘制过程
- 第一看变量”部分的材料上。
- 图文详解Andorid中用Shape定义GradientDrawable
- 七牛------iOS多文件上传demo
- axis2开发之---生成Java代码(4)
- cocos2dx(一)-ios平台程序怎么跑起来的
- SPOJ HIGH - Highways
- C# 中DateTime的各种使用
- 同步linphone
- HTML5 - 使用<time>标注日期和时间
- 应用程序内部实现语言国际化
- 多态朦胧中走进我们的生活