我尝试在json结构中发送多个文件,如下所示:
files = {
file1 = {
nfo1 = "text 1 1",
nfo2 = "text 1 2",
data = <DATA>,
},
file2 = {
nfo1 = "text 2 1",
nfo2 = "text 2 2",
data = <DATA>,
},
}
我认为我必须使用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];
但我不了解使用appendPartWithFileData识别file1和file2数据的方法!...
答案 0 :(得分:1)
我明白了:
[formData appendPartWithFileData:fileData1 name:@"files[file1[data]]" fileName:fileName1 mimeType:mimeType1];
[formData appendPartWithFileData:fileData2 name:@"files[file2[data]]" fileName:fileName2 mimeType:mimeType2];