I am trying to upload an image to server by converting the image to base64 encoded string. Below is the conversion code:
let imageData:NSData = UIImagePNGRepresentation(self.selImage!)! as NSData
var base64String = imageData.base64EncodedString(options:NSData.Base64EncodingOptions(rawValue: 0))
self.panBaseStr = base64String
I am getting an error from server as :
Payload is too high
It is due to a large base64 string.
And when I try to print the base64 encoded string, it takes too much time. Any specific reason for this?
How can I downscale the encoded string?
I running this code on simulator and XCODE version is 8 and using Alamofire for API calls.
Please note: The requirement is to send image as an encoded string to server rather than the image file.