问题
On this website, for example when you drop in an image, it is turned into a proper base64 format: http://base64image.org/
In my Swift app, here is what I have to generate a base64 string from an image:
let image_Data = UIImagePNGRepresentation(default_image)
let base64String = image_Data!.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
This gives me something similar, but it has spaces and line breaks. How do I get an output just like the output from the website above?
回答1:
let image_Data = UIImagePNGRepresentation(default_image)
let base64String = image_Data!.base64EncodedStringWithOptions([]) // Don't ask for line breaks
If you remove the request for line breaks, does it match what you're expecting?
来源:https://stackoverflow.com/questions/34406024/swift-base64-format