【发布时间】:2017-02-12 14:29:31
【问题描述】:
我有一个关于使用 Alamofire 将图像上传到 API 服务器的问题。
基本网址:http://vietnamtravelguide-app.com/quangnam/api_inquangnam/tips/create?user_id=""&token="" 3个参数:location_id、content、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 返回失败
【问题讨论】: