i have array of parameters and array of images each set of parameter contain one and only one image.my code
let imgData = UIImageJPEGRepresentation(imageView.image!, 0.2)!
Alamofire.upload(multipartFormData: { multipartFormData in
multipartFormData.append(imgData, withName: "fileset",fileName: "file.jpg", mimeType: "image/jpg")
for (key, value) in params {
multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
}
},
to:URLUpdateProfile,
method:.post,
headers:headers)
{ (result) in
switch result {
case .success(let upload, _, _):
upload.uploadProgress(closure: { (progress) in
print("Upload Progress: \(progress.fractionCompleted)")
})
upload.responseJSON { response in
print(response.result.value)
}
case .failure(let encodingError):
print(encodingError)
}
}
with this code i am able to upload one image along with one parameter.but i want to send parameter in array and image in array too.is the way to upload array of params with array of image? if yes how to track image and parameter?
You can upload each image and its param in an
Operation
. YourOperation
should look something like this:Then you create the operations and add them to the queue like this: