Converting NSData to NSString without encoding

二次信任 提交于 2019-12-08 10:08:38

问题


I am trying to upload a image onto server's database.

For that I have done

  1. Converted image to nsdata using UIImageJPEGReprenstation.
  2. Converted nsdata to nstring using base64lib.

Problem here is that nsstring that I have is NSASCII encoded.

So the default open ssl converters are not able to read the file and convert it into correct images on server side.

So what i need is

The nsstring that I have created from nsdata must not be encoded using nsascii or nsutf8 or something, as the image data is binary.

Or

On server side i must decode the data back to binary from nsascii or whatever way I have encoded on client side. But here the issue is I do not have any inbuilt api for ascii decoding.


回答1:


Why do you need to convert the image data to string data? Couldn't you just do an HTTP POST with jpg data (MIME image/jpeg)? This post shows you how to do it.



来源:https://stackoverflow.com/questions/7687895/converting-nsdata-to-nsstring-without-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!