ios - Ambiguous reference to member upload alamofire -
i receiving error when trying upload picture web server. copied , pasted alamofire sample github , receive error right away. code follows:
let data = uiimagejpegrepresentation(picoutlet.image, 0.5) alamofire.upload(.post, "phpurlhere", file: photo) .progress { byteswritten, totalbyteswritten, totalbytesexpectedtowrite in print(totalbyteswritten) // closure not called on main queue performance // reasons. update ui, dispatch main queue. dispatch_async(dispatch_get_main_queue()) { print("total bytes written on main queue: \(totalbyteswritten)") } } .validate() .responsejson { response in debugprint(response) }
update: added jpeg representation pass alamofire function still getting same error.
the issue upload
function:
alamofire.upload(.post, "phpurlhere", file: photo)
is expecting object of type nsurl
file:
parameter. giving uiimage
.
if goal upload picoutlet.image
using upload
function, try following:
let data = uiimagejpegrepresentation(picoutlet.image, 0.5) alamofire.upload(.post, "phpurlhere", data: data) .progress { byteswritten, totalbyteswritten, totalbytesexpectedtowrite in print(totalbyteswritten) // closure not called on main queue performance // reasons. update ui, dispatch main queue. dispatch_async(dispatch_get_main_queue()) { print("total bytes written on main queue: \(totalbyteswritten)") } } .validate() .responsejson { response in debugprint(response) }
Comments
Post a Comment