1

I have a restful wcf service. I have to send images from service to android app. I can not use or provide direct url of images to download for security reasons. Images are less than 2MB in size. I am using ByteArray to send image from WCF service to Android app in json, as :

<OperationContract()> _
<WebGet(UriTemplate:="/GetFile", ResponseFormat:=WebMessageFormat.Json, RequestFormat:=WebMessageFormat.Json)> _
Function GetFile(Byval Token as String) As Byte()

GetFile function returns an image as ByteArray. I am confused as i have gone through many websites.

Is the byte array converted to Base64String. If yes then the image received by android client will be about 30% more in size.

My question is

What is the best way to send image (less than 2MB) from restful wcf to android app without increasing its data size. (without any Base64 or any conversion)?

Sending image as Stream rather than ByteArray creates an overhead to the server and high memory use?

1 Answer 1

1

ByteArray is not good practice. serializing ByteArray is too slow. in order to solve this problem suggested to convert ByteArray to Base64String. but if you don't want to increase the size you can stream the image. sending stream has no overhead but you cant serialize anything else with your stream. which its OK in your case.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.