이죠 우리가 여기이진
아래처럼 나는, 바이너리로 이미지를 업로드 원하는 이미지를 업로드하는 방법, 그 요구가 아닌 것 같습니다 내 코드
var url = myURLString
url = url.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!
guard let imageData = UIImageJPEGRepresentation(image, 0.4) else {
return
}
request.httpBody = imageData
request.httpMethod = "POST"
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
Alamofire.request(request).responseJSON { (response) in
if let JSON = response.result.value as? NSDictionary {
print(JSON)
} else {
let message = response.result.error != nil ? response.result.error!.localizedDescription : "Unable to communicate."
print(message)
}
}
입니다 이미지 파일 첨부 중 다음 오류 메시지가 표시됨
" 응답을 직렬화 할 수 없으며 입력 데이터가 없거나 길이가 0입니다. "
이유는 단지'Alamofire.upload (...)'를 사용하지? – user28434
가능한 복제본 [alamofire.error Code = -6006 "JSON을 직렬화 할 수 없음] (https://stackoverflow.com/questions/35374798/alamofire-error-code-6006-json-could-not-be-serialized) – AshvinGudaliya
'responseJSON' 대신'responseString'을 시도해보고 어떤 오류가 나고 있는지 확인하십시오. –