/*
* amrData 音频文件
* dict 你要是不用当然可以不传啦...看项目
*/
+ (void)uploadAudioWithAudio:(NSData *)amrData
withParams:(NSMutableDictionary *)dict
successCallback:(void(^)(NSDictionary *))success
withFailCallback:(void(^)(NSError *))fail;
+ (void)uploadAudioWithAudio:(NSData *)amrData
withParams:(NSMutableDictionary *)dict
successCallback:(void(^)(NSDictionary *))success
withFailCallback:(void(^)(NSError *))fail
{
AFHTTPSessionManager * manager = [AFHTTPSessionManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager POST:[NSString stringWithFormat:@"%@/webupload/wenda",kWebURLDefine] parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
//123.amr 约定啊
[formData appendPartWithFileData:amrData name:@"file" fileName:@"123.amr" mimeType:@"audio/mpeg"];
} progress:^(NSProgress * _Nonnull uploadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSDictionary *dict = (NSDictionary *)responseObject;
success(dict);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[manager.operationQueue cancelAllOperations];
fail(error);
}];
}