I'm trying to send multiple files in json structure like this :
files = {
file1 = {
nfo1 = "text 1 1",
nfo2 = "text 1 2",
data = <DATA>,
},
file2 = {
nfo1 = "text 2 1",
nfo2 = "text 2 2",
data = <DATA>,
},
}
I think i have to do something like this with AFHTTPSessionManager :
NSDictionary *parameters = @{@"files":@{
@"nfo1" = @"text 1 1",
@"nfo2" = @"text 1 2",
},
@{
@"nfo1" = @"text 2 1",
@"nfo2" = @"text 2 2",
}
};
[self POST:path parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:fileData1 name:@"data" fileName:fileName1 mimeType:mimeType1];
[formData appendPartWithFileData:fileData2 name:@"data" fileName:fileName2 mimeType:mimeType2];
} success:nil failure:nil];
But i don't understand the way to identify data for file1 and for file2 using appendPartWithFileData !...
I got it :
[formData appendPartWithFileData:fileData1 name:@"files[file1[data]]" fileName:fileName1 mimeType:mimeType1];
[formData appendPartWithFileData:fileData2 name:@"files[file2[data]]" fileName:fileName2 mimeType:mimeType2];