title: Video stream from client to server in NodeJS
body: <p>I'm currently developing an application to stream video feed from client to server in NodeJS. The server side code is as shown below</p>
  <p><strong>server.js</strong></p>
  <pre><code>const express = require('express')
  const app = express()
  const morgan = require('morgan')
  const server = require('http').Server(app)
  const io = require('socket.io')(server)
  const auth = require('./routes/auth')
  const video = require('./routes/videoproc')(io)
  
  
  const bodyParser = require('body-parser')
  
  
  app.use(bodyParser.json())
  app.use(bodyParser.urlencoded({extended: true}))
  app.use(morgan('dev'))
  app.use(&quot;/users&quot;, auth)
  app.use(&quot;/exam&quot;, video);
  
  
  server.listen(3000)
  </code></pre>
  <p><strong>videoproc.js</strong></p>
  <pre><code>const express = require('express')
  const video = express.Router()
  const ss = require('socket.io-stream')
  const fs  = require('fs')
  const path = require('path')
  
  module.exports = (io) =&gt; {
      video.post('/video', (req, res) =&gt; {
          io.on('connection', (socket) =&gt; {
              ss(socket).on('video', (stream, data) =&gt; {
                  const fileName = path.basename('test')
                  stream.pipe(fs.createWriteStream(fileName))
              })
          })
      })
      return video
  }
  </code></pre>
  <p>This is the <strong>client side code</strong></p>
  <pre><code>var io = require('socket.io-client');
  var ss = require('socket.io-stream');
  var fs = require('fs')
  var socket = io.connect('http://localhost:3000/exam/video/');
  var stream = ss.createStream();
  var filename = './test.webm';
   
  ss(socket).emit('video', stream, {name: filename});
  fs.createReadStream(filename).pipe(stream);
  </code></pre>
  <p>As a test I've send a video feed to the server but the file is not being stored, some help to solve this issue is appreciated.</p>