我们正在尝试使用POST方法上传到API。我们正试图推动一个形象。我们收到了下一个错误
success(request: 2018-02-03 16:27:53.087629-0800 Optimio-iOS[5425:201118] CredStore - performQuery - Error copying matching creds. Error=-25300, query={
class = inet;
"m_Limit" = "m_LimitAll";
ptcl = htps;
"r_Attributes" = 1;
sdmn = "llegoelbigotes.ubiqme.es";
srvr = "llegoelbigotes.ubiqme.es";
sync = syna;
}
$ curl -v \
-X POST \
-H "Content-Type: multipart/form-data; boundary=alamofire.boundary.7105b62be90b880b" \
-H "Accept-Language: en;q=1.0, es-ES;q=0.9" \
-H "Authorization: Token 1b0ad885a95334154ca3bfa79b3f52ca35c25e0e" \
-H "User-Agent: Optimio-iOS/1.0 (Ubiqme-com.ubiqme.ubiqme; build:1; iOS 11.2.0) Alamofire/4.6.0" \
-H "Accept-Encoding: gzip;q=1.0, compress;q=0.5" \
"https://llegoelbigotes.ubiqme.es/api/new-ticket", streamingFromDisk: true, streamFileURL: Optional(file:///Users/polvallsortiz/Library/Developer/CoreSimulator/Devices/EE663E81-6611-4B69-ABD6-AF97D19D6FB7/data/Containers/Data/Application/E7B9F357-DD51-4512-8173-37C932C0E4B9/tmp/org.alamofire.manager/multipart.form.data/74C9B75E-614D-4FCD-9DBC-1F5D07D773C4))
我们的代码是下一个代码:
func myImageUploadRequest() {
guard let urlStr = "https://llegoelbigotes.ubiqme.es/api/new-ticket".addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed),
let url = URL(string: urlStr)
else {return}
let isPaymentCard = card ? "true" : "false"
let headers: HTTPHeaders = ["Authorization": "Token \(token!)"]
let param = [ "comment": comment, "category": String(category), "amount": String(money), "payment_card": isPaymentCard ]
Alamofire.upload(multipartFormData: { multipartFormData in
if let imageData = UIImageJPEGRepresentation(self.image,0.5)
{ multipartFormData.append(imageData,withName:"image",fileName:"image.jpeg",mimeType:"image/jpeg") }
for(key,value) in param {
multipartFormData.append("\(value)".data(using: String.Encoding.utf8)!, withName: key as String)
}
}, usingThreshold: UInt64.init(),
to: urlStr,
method: .post,
headers: headers) {(result) in
print(result)
switch result{
case .success(let upload, _, _):
upload.responseJSON {
response in
print("Succesfully uploaded")
if let err = response.error{
print(err)
return
}
}
case .failure(let error):
print("Error in upload: \(error.localizedDescription)")
print(error)
}
}
}
任何人都可以向我们展示一些提示或说出可能出错的地方? 感谢所有社区!