Swift3 Swift 3和IBM Cloudant上载一个映像
我尝试了很多方法,用Swift将一个简单的Swift3 Swift 3和IBM Cloudant上载一个映像,swift3,cloud,image-uploading,Swift3,Cloud,Image Uploading,我尝试了很多方法,用Swift将一个简单的UIImage上传到ibmcloundant,但没有成功。我也试过阿拉莫菲尔 请帮帮我 let imageData = UIImagePNGRepresentation(imageToUpload) Alamofire.upload(imageData!, to: url) .authenticate(usingCredential: credential) .responseJSON { response in debugPrint(respo
UIImage
上传到ibmcloundant,但没有成功。我也试过阿拉莫菲尔
请帮帮我
let imageData = UIImagePNGRepresentation(imageToUpload)
Alamofire.upload(imageData!, to: url)
.authenticate(usingCredential: credential)
.responseJSON { response in
debugPrint(response)
}
错误类型不正确,需要是JSON
。所以我试着这样做:
let imageData = UIImagePNGRepresentation(imageToUpload)
let dict = ["image": imageData]
let data = try? JSONSerialization.data(withJSONObject: dict, options: .prettyPrinted)
Alamofire.upload(data!, to: url)
.authenticate(usingCredential: credential)
.responseJSON { response in
debugPrint(response)
}
你试了什么?什么不起作用?请分享您迄今为止所做的代码。我删除了很多,但问题是我认为要将JSON中的图像序列化为JSON,请检查这里: