我可以按套接字将文件上载到服务器吗?io node . js ?

时间:2021-04-10 17:08:49

I have a socket.io client to whom socket.io server is listening in node.js.I want to upload a file to server by socket.io. because my socket.io client is under apache. and socket.io server is in node.js. I want to code uploading of file in node.js. But how i can send the file data to the node.js listening to socket.

我有一个套接字。io客户端。io服务器正在监听node.js。我想通过socket.io向服务器上传一个文件。因为我的套接字。io客户端在apache之下。和套接字。io服务器在node.js中。我想用node.js编写文件上传代码。但是如何将文件数据发送到节点。js听插座。

I have tried the upload of a file using node.js server. This link is here but the this code does not use the socket.io with this. But my original project is using the socket.io.

我尝试过用node上传文件。js服务器。这个链接在这里,但是这个代码不使用套接字。io。但我最初的项目是使用socket.io。

http://rahulmehta1.wordpress.com/2011/04/26/uploading-a-file-in-node-js-by-formidable/

http://rahulmehta1.wordpress.com/2011/04/26/uploading-a-file-in-node-js-by-formidable/

How can i do this with the socket.io server?

我怎么能用这个插座呢?io服务器?

5 个解决方案

#1


25  

The checked answer is invalid as of Jul 3rd 2012.

检查的答案从2012年7月3日起无效。

Read by yourself this tutorial on NetTuts. This tutorial uses node.js and socket.io to upload a file.

请自己阅读本教程。本教程使用节点。js和套接字。io上传文件。

#2


9  

I wrote a module for this purpose.

为此我编写了一个模块。

socket.io-stream

socket.io-stream

#3


8  

Here is a npm module I wrote that will implement Socket.IO file uploading in your application:

下面是我编写的将实现套接字的npm模块。在你的申请中上传IO文件:

Socket.IO File Upload

套接字。输入输出文件上传

All you need to give the module is your middleware, your socket, and the file input or drop zone used for uploading files. It will also save the files if you give it a directory. The module takes care of the rest.

您所需要提供的模块是您的中间件、套接字和用于上传文件的文件输入或删除区域。如果给它一个目录,它也会保存文件。模块负责其余部分。

#4


5  

Here is an example of sending a file over socket.io: http://liamkaufman.com/blog/2012/02/11/12-pushing-files-to-the-browser-using-deliveryjs-socketio-and-nodejs/

下面是一个通过套接字发送文件的例子。io:http://liamkaufman.com/blog/2012/02/11/12-pushing-files-to-the-browser-using-deliveryjs-socketio-and-nodejs/

#5


4  

In May of 2014 with release version 1.0 of socket.IO, binary support has been added to the library.

2014年5月发布1.0版socket。IO,二进制支持已经添加到库中。

Socket.IO now supports emitting Buffer (from Node.JS), Blob, ArrayBuffer and even File, as part of any datastructure

套接字。IO现在支持作为任何数据结构的一部分释放缓冲区(来自Node.JS)、Blob、ArrayBuffer甚至文件

It's all due to low level api which is provided by engine.io.

这都是由于低水平的api,由engine.io提供。

#1


25  

The checked answer is invalid as of Jul 3rd 2012.

检查的答案从2012年7月3日起无效。

Read by yourself this tutorial on NetTuts. This tutorial uses node.js and socket.io to upload a file.

请自己阅读本教程。本教程使用节点。js和套接字。io上传文件。

#2


9  

I wrote a module for this purpose.

为此我编写了一个模块。

socket.io-stream

socket.io-stream

#3


8  

Here is a npm module I wrote that will implement Socket.IO file uploading in your application:

下面是我编写的将实现套接字的npm模块。在你的申请中上传IO文件:

Socket.IO File Upload

套接字。输入输出文件上传

All you need to give the module is your middleware, your socket, and the file input or drop zone used for uploading files. It will also save the files if you give it a directory. The module takes care of the rest.

您所需要提供的模块是您的中间件、套接字和用于上传文件的文件输入或删除区域。如果给它一个目录,它也会保存文件。模块负责其余部分。

#4


5  

Here is an example of sending a file over socket.io: http://liamkaufman.com/blog/2012/02/11/12-pushing-files-to-the-browser-using-deliveryjs-socketio-and-nodejs/

下面是一个通过套接字发送文件的例子。io:http://liamkaufman.com/blog/2012/02/11/12-pushing-files-to-the-browser-using-deliveryjs-socketio-and-nodejs/

#5


4  

In May of 2014 with release version 1.0 of socket.IO, binary support has been added to the library.

2014年5月发布1.0版socket。IO,二进制支持已经添加到库中。

Socket.IO now supports emitting Buffer (from Node.JS), Blob, ArrayBuffer and even File, as part of any datastructure

套接字。IO现在支持作为任何数据结构的一部分释放缓冲区(来自Node.JS)、Blob、ArrayBuffer甚至文件

It's all due to low level api which is provided by engine.io.

这都是由于低水平的api,由engine.io提供。