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

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -