简体   繁体   English

通过 Web 服务发送图像

[英]Sending an Image through Web Service

I've been having a few thoughts on how to send an actual image through a web service.关于如何通过网络服务发送实际图像,我一直有一些想法。 I'm retrieving it from a database as a Binary Data code, which is huge.我从数据库中检索它作为二进制数据代码,这是巨大的。 I'm unsure if I have to send it like that through the web service and then the client deciphers the image from the code, or if the server does that and sends it exactly as an image file.我不确定我是否必须通过 Web 服务发送它,然后客户端从代码中解密图像,或者服务器是否这样做并将其完全作为图像文件发送。 The ideal here would be to do that on the server side, though I have no idea if it's possible or even how.这里的理想是在服务器端执行此操作,尽管我不知道这是否可能或什至如何。 Any ideas?有任何想法吗?

I would say send it as a string and process it on the client side.我会说将其作为字符串发送并在客户端进行处理。 If you convert it to a base 64 string then you can send it as text and the client can display it using data:image如果将其转换为 base 64 字符串,则可以将其作为文本发送,客户端可以使用 data:image 显示它

<img src="data:image/png;base64,iVBORw0KGgoAAAANS..." />

Since you said it is a web service I am assuming the client is a website.既然你说它是一个网络服务,我假设客户端是一个网站。

If you want to do it on the server side than you might as well store it as an image file on the server and just send the uri.如果您想在服务器端执行此操作,不如将其作为图像文件存储在服务器上,然后发送 uri。

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

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