简体   繁体   中英

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. 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

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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