简体   繁体   English

通过套接字发送base64编码图像

[英]Sending base64 encode images over a socket

We currently are building a chat like social service, running on a node.js using sockets. 当前,我们正在使用套接字在node.js上运行类似社交服务的聊天。 the code is running fine but we have some strange behaviour when sending an encoded image(base64) over the line. 该代码运行良好,但是通过该行发送编码的图像(base64)时,我们会有一些奇怪的行为。 it takes ages for the image to arrive around 1/2 minutes. 到达图像大约需要1/2分钟的时间。 This is tested localhost for both the client and the server 客户端和服务器都经过了本地主机测试

We can't find the issue this is the server sided code in question. 我们找不到问题,这是有问题的服务器端代码。 the iPhone app uses the GCDAsync Library and logs everytime a write has finished. iPhone应用程序使用GCDAsync库,并在每次写入完成时记录日志。 (this is almost instant) only the server is getting it a minute or two after it has been send. (这几乎是即时的)只有服务器在发送后一两分钟才收到。 The image in question is 48kb 该图像为48kb

Server Partial Source 服务器部分来源

Thank you for your help. 谢谢您的帮助。 i can't seem to find the issue i hope stackoverflow can ! 我似乎找不到我希望stackoverflow可以解决的问题!

I was facing same issue while sending image via Sockets. 通过套接字发送图像时遇到相同的问题。

Like you I was sending base64 via sockets 像你一样,我通过套接字发送base64

What I Did, I resized my image to 150px x 150px and converted that into base64 and sent it to socket. 我做了什么,我将图片的尺寸调整为150px x 150px,并将其转换为base64并将其发送到套接字。 Meanwhile I uploaded original image to server whose URL I added to base64 message. 同时,我将原始图像上传到服务器,该服务器的URL已添加到base64消息中。 Now at receiver end, you need to convert base64 to image which is thumbnail, and you can either download large image in back ground or you can give user an option to download large images. 现在在接收器端,您需要将base64转换为缩略图图像,并且可以在后台下载大图像,也可以为用户提供下载大图像的选项。 This is how whats app and other messaging App works 这是什么应用程序和其他消息传递应用程序的工作方式

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

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