我要把图片换成nsdata,然后再用base64encoding,把encoding后生成的字符串上传到
服务器,就出这个问题,
报错信息:err:Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: 请求太大 (413)"
我同事用的ASIHTTPRequest库就没问题,请问如何解决?
代码:
UIImage *img = [self createThumbnailWithSourceImge:sourceImg andNewSize:sz];
data = UIImageJPEGRepresentation(img, 0.01);
NSString *encodedSTR = [data base64Encoding];
NSString *currentUrl = @"/app/b/test";
NSString *urlStr = [NSString stringWithFormat:@"%@%@?picStr=%@",BASEURL,currentUrl,encodedSTR];
NSURL *url = [NSURL URLWithString:urlStr];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc]initWithRequest:request];
op.responseSerializer = [AFJSONResponseSerializer serializer];
[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
// NSLog(@"success:%@",responseObject);
successBlock(responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
failureBlock(error);
}];
[op start];
// [manager POST:urlStr parameters:nil
// success:^(AFHTTPRequestOperation *operation, id responseObject) {
// NSLog(@"success:%@",responseObject);
// } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// NSLog(@"err:%@",error);
// }];