NSURLSession convert image during uploading

65 Views Asked by At

I am uploading an image to my server, and meantime JPG image get converted, and converted image will not anymore readable.

Tried to set HTTP "Cache-Control", but no effect it has.

Any idea how to prevent conversion?

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()

Attached the look of the before and after image data.

enter image description here

0

There are 0 best solutions below