I am trying to upload picture to server, via af 2.0 multipart request, but it seems body is always null. Here is a snapshot from code:
[self POST:path parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFormData:file name:@"file"];
} success:^(NSURLSessionDataTask *task, id responseObject) {
andAPIResponseType:apiResponseType];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
}];
where file is photo that i took from device camera and did something like this
NSData *file = UIImageJPEGRepresentation(avatar, 0.5)
However when i log what i send via AF logger, i get something like this
103762376897069058/avatar?access_token=4f77072f0f7de259293f229c7a876130c79705d7': {
"Accept-Language" = "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5";
"Content-Length" = 29120;
"Content-Type" = "multipart/form-data; boundary=Boundary+0xAbCdEfGbOuNdArY";
"User-Agent" = "MixHR/0.0.1 (iPhone; iOS 7.0.4; Scale/2.00)";
} (null)
So why is body nil? I tried logging file, it is not empty.
You try this code: