0
我有一个关于使用Alamofire将图像上传到API服务器的问题。使用Alamofire将图像上传到API服务器
的BaseURL:http://vietnamtravelguide-app.com/quangnam/api_inquangnam/tips/create?user_id= “” &令牌= “” 3个参数:LOCATION_ID,内容,imageName
这是确定由邮差
我的代码发布:
Alamofire.upload(multipartFormData: { multipartFormData in
multipartFormData.append(image, withName: "imageName", fileName: "swift_file.jpeg", mimeType: "image/jpeg")
}, with: path, encodingCompletion: {encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.responseJSON { response in
print(response.result)
switch response.result {
case .success:
let json = JSON(response.result.value!)
if(delegate != nil) {
delegate!.didReceiveResult(json,basePath: basePath)
}
case .failure(let error):
print(error)
} }
case .failure(let encodingError):
print(encodingError)
}
})
带有图像的
(从参数强制转换为图像的图像)。当我调试它,我得到response.result返回失败
是的解决,我错过了2个参数,并编码它。非常感谢。 –