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個參數,並編碼它。非常感謝。 –