I have a Frontend application sending file over HTTP to Nodejs Backend. The Nodejs application acts as a socketio server and needs to send the file to a python socketio client. I have used multer to parse the HTTP request. Here are the nodejs and python code I have written so far (only pasted required parts)
// NodeJS server code I have written so far (could be completely wrong)
// req.file contains the file parsed from multer
var socket = req.app.get('socket');
let readStream = createReadStream(req.file.path);
readStream.on('ready', () => {
socket.emit('image', readStream, data => console.log(data));
readStream.pipe(createWriteStream(req.file.originalname));
});
# Python socketio client
@sio.event
async def image(data):
try:
print(data)
# want to save data preferably in a local file or a buffer is also fine
except:
return 'NOT OK'
finally:
return 'OK'
I am facing issues on both fronts, for both of which I have almost no idea how to procede: