答案 0 :(得分:0)
试试这个
Alamofire.upload(.POST, API_URL, multipartFormData: { (formData:MultipartFormData) in
formData.appendBodyPart(fileURL: NSURL(fileURLWithPath: filePath), name: name)
}, encodingCompletion: { encodingResult in
switch encodingResult {
case .Success(let upload, _, _):
upload.progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
print(totalBytesRead)
}
upload.responseJSON { response in
debugPrint(response)
//uploaded
}
case .Failure(let encodingError):
//Something went wrong!
if DEBUG_MODE {
print(encodingError)
}
}
})