NSURLSession在上传过程中转换图像

时间:2016-05-27 11:34:26

标签: ios nsurlrequest nsurlrequestcachepolicy

我正在将图像上传到我的服务器,同时转换JPG图像,转换后的图像将不再可读。

尝试设置HTTP“Cache-Control”,但没有效果。

知道如何防止转换吗?

let url: NSURL = NSURL(string: "xxx")!
let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "POST"
request.setValue("private, no-store, no-cache, must-revalidate, no-transform, max-age=0", forHTTPHeaderField: "Cache-Control")
request.HTTPBody = NSData(contentsOfFile: path)

let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
NSURLSession(configuration: configuration).dataTaskWithRequest(request, completionHandler: {data, urlRequest, error in }).resume()

附上前后图像数据的外观。

enter image description here

0 个答案:

没有答案