我正在尝试为 Swift 3 和 Alamofire 4 转换代码,我目前正在努力解决以下错误:
Cannot call value of non-function type '((UInt) -> Data?)!'
在这一行:
multipartFormData.append(data: value!.data(using: String.Encoding.utf8.rawValue)!, name: key)
请对此案提出您的建议。我当前的代码如下。
Alamofire.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(imageData!, withName: "image", fileName: nowString + "To" + receiverString! + ".jpg", mimeType: "image/jpg")
for (key, value) in parameters {
multipartFormData.append(data: value!.data(using: String.Encoding.utf8.rawValue)!, name: key)
}
},to:"uploadimgURL"
encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _)
upload.responseString(completionHandler: { (response) in
debugPrint(response)
})
case .failure(let encodingError):
print(encodingError)
}
}
)