使用Alamofire上传带有参数的文件

使用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)
 }

我有状态码415吗?

另外,如何在上传中发送额外的Params?


喵喔喔
浏览 1844回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP