Converting NSData to NSString without encoding

1.2k Views Asked by At

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

There are 1 best solutions below

2
On

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.