使用Alamofire上传带有参数的文件
Alamofire
NSUrl
NSData
var url:NSURL = NSURL.URLWithString("http://localhost:8080/bike.jpeg") var err: NSError? var imageData :NSData = NSData.dataWithContentsOfURL(url,options: NSDataReadingOptions.DataReadingMappedIfSafe, error: &err) Alamofire.upload(.POST, "http://localhost:8080/rest/service/upload/test.png", imageData) .progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in println(totalBytesWritten) } .responseJSON { (request, response, JSON, error) in println(request) println(response) println(JSON) }
相关分类