How do you upload multiple files with AFNetworking

前端 未结 1 955
野性不改
野性不改 2020-12-08 17:25

I can upload a single file without any issues but now I find that I need to upload 1 or more files, does anyone know how to do this with AFNetworking?

Any help would

相关标签:
1条回答
  • 2020-12-08 18:05

    Use a multipartFormRequest

    NSURLRequest* request = [[YourHTTPClient sharedHTTPClient] multipartFormRequestWithMethod:@"POST"
                             path:path
                             parameters:dict
                             constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
                                  [formData appendPartWithFileData:data1
                                                              name:@"image1"
                                                              fileName:@"image1.jpg"
                                                              mimeType:@"image/jpeg"];
                                  [formData appendPartWithFileData:data2
                                                              name:@"image2"
                                                              fileName:@"image2.jpg"
                                                              mimeType:@"image/jpeg"];
                             }
                         }];
    
    0 讨论(0)
提交回复
热议问题