Я пытаюсь загрузить массив изображений на сервер, используя Alamofire 4.8.2
Вот функция:
func uploadMultiplePhotos(centreId: Int, imagesArray: [UIImage]) {
let parameters = ["ec_id": centreId, "uploaded_image": imagesArray] as [String : Any]
Alamofire.upload(multipartFormData: { (multipartFormData : MultipartFormData) in
let count = imagesArray.count
for i in 0..<count{
multipartFormData.append(imagesArray[i], withName: "photo[\(i)]", fileName: "photo\(i).jpeg", mimeType: "image/jpeg")
}
for (key, value) in parameters {
multipartFormData.append((value as AnyObject).data(using: String.Encoding.utf8.rawValue)!, withName: key)
}
print(multipartFormData)
}, to: storeCentreImageURL) { (result) in
switch result {
case .success(let upload, _ , _):
upload.uploadProgress(closure: { (progress) in
print("uploding: \(progress.fractionCompleted)")
})
upload.responseJSON { response in
print(response.result.value!)
}
case .failure(let encodingError):
print("failed")
print(encodingError)
}
}
}
получить ошибку в строке ниже:
multipartFormData.append(imagesArray[i], withName: "photo[\(i)]", fileName: "photo\(i).jpeg", mimeType: "image/jpeg")
Невозможно вызвать 'append' со списком аргументов типа '(UIImage, withName: String, fileName: String, mimeType: String)'