0

I have a wcf service that is used by android/ios and a websetie(admin panel),

Users can upload and retrieve images.

For now, I am using base64 encoding for uploading and retrieving. For example, user uploads images with base64 encoding ( i am converting it behind) and wcf converts base64 as an image and storages as an image file to a folder. And when user retrieves an image, wcf reads the image file and converts it as an base64 and send it.

For example, base64 string length of a small image thats file size is 17kb, is 22432. I think its a huge string. If i sends or retrieves bigger file, will be much more than it.

So I think that that way is not so efficient. First of all I thought using string compressing but after i thought i can send it with another way.. like byte array?

I am not sure which way is more effective, what is the best way for that?

I hope, the question is enough clear.

ertan2002
  • 1,458
  • 1
  • 32
  • 68
  • You can use streaming and send raw byte[]. See my answer here http://stackoverflow.com/questions/33101969/file-upload-in-wcf-service-413-request-entity-too-large/33119897#33119897 – Mimas Nov 12 '15 at 14:20
  • @Mimas, thank you for your reply, I am using basichttpbinding, its a soap, i forgot to say it. – ertan2002 Nov 12 '15 at 14:46
  • @ertan2002 - You can use streaming with `basicHttpBinding`. It's not limited to `webHttpBinding`. – Tim Nov 12 '15 at 17:18

1 Answers1

1

Find here (http://www.abhisheksur.com/2010/09/progress-streamed-file-download-and.html) complete sample for basicHttpBinding.

There is no difference in terms of service design. You create a method which accepts Stream or a message contract with stream, and then simply assign your stream to this member.

Then call a method.

The only things you should not forget to do is to Seek() the pointer to the stream begin before you have called the method, to make it readable.

Mimas
  • 525
  • 3
  • 7