简体   繁体   English

用于图像的Base64编码

[英]Base64 encoding for images

I am building a service using WCF and I need to send over images. 我正在使用WCF构建服务,我需要发送图像。 I looked around on how this is done and found that Base64 encoding is often used to send binary data as text. 我查看了这是如何完成的,并发现Base64编码通常用于将二进制数据作为文本发送。 Is this a good practice to send over images (~500 kb)? 这是一个很好的做法发送图像(~500 kb)?

Base64 is safely encodes binary data, it will be fine. Base64可以安全地编码二进制数据,没问题。 Just keep in mind it makes the transfer size about 30% larger. 请记住,它会使传输大小增加约30%。

That's a really big message, but yes, if you must send them, base 64 is the way to go. 这是一个非常重要的信息,但是,如果你必须发送它们,那么基础64就是你要走的路。 If you only have .net clients then you could look at binary message encoding to shrink the size down 如果您只有.net客户端,那么您可以查看二进制消息编码以缩小大小

Why do you need to send the binary data as text? 为什么需要将二进制数据作为文本发送? HTTP can send binary data, why not make your image available via HTTP and send a URL in your WCF service? HTTP可以发送二进制数据,为什么不通过HTTP提供图像并在WCF服务中发送URL?

We have sent images / files over WCF using byte arrays, up to several MB in size. 我们使用字节数组通过WCF发送图像/文件,最大可达几MB。

You can use MTOM for large files. 您可以将MTOM用于大文件。 See: 看到:

http://developers.de/blogs/damir_dobric/archive/2008/02/02/wcf-mtom-binary-data-transmission.aspx http://developers.de/blogs/damir_dobric/archive/2008/02/02/wcf-mtom-binary-data-transmission.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM