开发者

Best way / Fasters way to transfer an image via webservice

开发者 https://www.devze.com 2023-01-08 09:25 出处:网络
what is the best way t开发者_开发百科o transfer an 800*600 image via a webservice using C#? I am looking for a fast method.

what is the best way t开发者_开发百科o transfer an 800*600 image via a webservice using C#?

I am looking for a fast method.

thanks


If you are using WCF 4.0 then you could use socket programming and from there you could transmit as binary (compressed with 7zip of course).

If the image is already in a compressed format (jpeg for example) then compression would not be that great and it would slow down the actual total transfer (compress - transmit - decompress).


If you're using WSE, consider using MTOM.

If you're using WCF, you could use an MTOM binding.


If you want to save bandwidth/Speed (Not tested on many different image formats)

7zip C# SDK (http://www.7-zip.org/sdk.html) 7-Zip the bytes and send the bytes

and where needed un"7-Zip" (LZMA) the bytes and convert to image.


You'll probably want to send the image in small pieces (even if it's zipped up as Chris Schroeder mentioned), say 50K at a time. This gives you two advantages over sending the entire file at once:

  • You can show progress to the user
  • If one piece fails to transmit then you only have to send that piece rather than the whole file

However, with this method is you now have 2 new problems to handle and that is making sure you get ALL of the pieces, and that they're in the correct order.

Sending some metadata with the image data can fix this situation. An identifier that relates this piece of data with the others, and the piece number which will determine where this piece should be in relation to the rest of the pieces.

0

精彩评论

暂无评论...
验证码 换一张
取 消