// 请求参数
NSMutableDictionary *baseParameters = [self baseParametes];
[baseParameters setObject:apikey forKey:@"apikey"];
[baseParameters setObject:secret forKey:@"secret"];
[baseParameters setObject:sn forKey:@"sn"];
[baseParameters setObject:filename forKey:@"filename"];
[baseParameters setObject:objectname forKey:@"objectname"];
[baseParameters setObject:clienttype forKey:@"clienttype"];
[baseParameters setObject:@(filetype) forKey:@"filetype"];
[baseParameters setObject:@(filesize) forKey:@"filesize"];
[baseParameters setObject:time forKey:@"time"];
// 网络加载标志
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
// AF
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
// multipart/form-data
[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[manager.requestSerializer setValue:@"multipart/form-data" forHTTPHeaderField:@"Content-Type"];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", @"text/xml", @"text/plain", nil];
[manager POST:[NSString stringWithFormat:@"%@%@",URL_OssFile,url]
parameters:nil
constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
NSData *data = [NSJSONSerialization dataWithJSONObject:baseParameters options:NSJSONWritingPrettyPrinted error:nil];
//[formData appendPartWithHeaders:@{@"Content-Type":@"multipart/form-data"} body:data];
[formData appendPartWithFormData:data name:@"log"];
}
progress:nil
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
callback(responseObject,nil);
}
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
saveLogFailed(K__ERROR);
}];
AF 表单提交数据 非文件
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- ajax提交表单数据 1.首先禁用form表单submit使用button按钮实现ajax传输!!! 前端代码: ...
- 使用webuploader上传文件,还要提交文件对应的属性。 思路:使用webuploader选择文件,上传文件,...
- 参考资料 https://docs.microsoft.com/en-us/aspnet/web-api/over...