使用socket.io nodejs将文件从android上传到服务器 [英] File upload from android to server with socket.io nodejs
问题描述
我已将 socket.io 集成到我的 android 应用程序中以制作聊天应用程序.现在我想上传和共享图像、mp3 或 doc 文件等文件.如何使用 socket.io 上传文件我找不到任何文档.
I have integrated socket.io into my android application to make a chat application. Now I wants to upload and share files like images, mp3 or doc file etc. How do I upload a file with socket.io I cannot find any documentation for doing.
推荐答案
这不是一个好的做法.如果上传进度很长,这可能会导致客户端和服务器之间的心跳消息阻塞.
It is not a good practice. This may lead blocking heartbeat messages between client and server if upload progress is long.
您可以上传带有 http 帖子的文件并将下载链接发送给聊天伙伴.通过这样做,会建立一个新的上传连接,并且不会中断 socket.io 会话.
You may upload file with http post and send download link to chat peer. By doing this, a new connection is established for uploading and never breaks socket.io session.
这篇关于使用socket.io nodejs将文件从android上传到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!