We have an IOS application which send images to a asp.net web api application. So we convert images to Base64 then we send it to the web service as a string .
The problem is that the size of the image is big so the conversion to base64 takes a lot of time and the size of the result string is bigger than the initial image's size.
I need to know :
- If another better way , instead of conversion to Base64, exists to convert the image before calling the web service
I used
Gzip
to compress/decompress an array of bytes like this :static byte[] Compress(byte[] data) { using (var compressedStream = new MemoryStream()) using (var zipStream = new GZipStream(compressedStream, CompressionMode.Compress)) { zipStream.Write(data, 0, data.Length); zipStream.Close(); return compressedStream.ToArray(); } }
Is it possible to convert image to array of bytes in IOS part then call the web service ? Or expose an object like compressedStream
or GZipStream
as a service argument?
Thanks,