Upload file using NodeJS and BusBoy

0 votes

I'm using NodeJS to upload a file. To save the stream in AWS SQS, I need to read the stream into a variable. The file should not be kept on disc, please. Can this be done? I only need the uploaded file into stream. I'm using the upload.js code:

var http = require('http');
var Busboy = require('busboy');

module.exports.UploadImage = function (req, res, next) {

    var busboy = new Busboy({ headers: req.headers });

    // Listen for event when Busboy finds a file to stream.
    busboy.on('file', function (fieldname, file, filename, encoding, mimetype) {

        // We are streaming! Handle chunks
        file.on('data', function (data) {
                // Here we can act on the data chunks streamed.
        });

        // Completed streaming the file.
        file.on('end', function (stream) {
            //Here I need to get the stream to send to SQS
        });
    });

    // Listen for event when Busboy finds a non-file field.
    busboy.on('field', function (fieldname, val) {
            // Do something with non-file field.
    });

    // Listen for event when Busboy is finished parsing the form.
    busboy.on('finish', function () {
        res.statusCode = 200;
        res.end();
    });

    // Pipe the HTTP Request into Busboy.
    req.pipe(busboy);
};

How do I get the uploaded stream?

Jun 22, 2022 in Node-js by Vaani
• 7,020 points
1,565 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Node-js

0 votes
1 answer

How to run shell script file using nodejs?

Hello @kartik, You could use "child process" module ...READ MORE

answered Oct 16, 2020 in Node-js by Niroj
• 82,840 points
5,766 views
0 votes
1 answer

NodeJS - Upload ~36MB file to VirusTotal failing

The VirusTotal file/scan API request has a ...READ MORE

answered May 27, 2022 in Node-js by Neha
• 8,940 points
203 views
0 votes
1 answer

Can't Upload Image with Google Photos API using NodeJS

The Google Photos API requires binary-formatted material, ...READ MORE

answered Jun 10, 2022 in Node-js by Neha
• 8,940 points
497 views
0 votes
0 answers

Issue in blob storage to fileShare big file transfer : Using fileRange (nodejs Cloud function)

To file a problem with blob storage ...READ MORE

Jun 13, 2022 in Node-js by Vaani
• 7,020 points
243 views
0 votes
1 answer

Download a file from NodeJS Server using Express

Because the file's name is just 'download' ...READ MORE

answered Jun 13, 2022 in Node-js by Neha
• 8,940 points
3,625 views
0 votes
0 answers

NodeJS, OpenCV and Streaming Images Using Net Socket

My ultimate goal is to have video ...READ MORE

Jun 21, 2022 in Node-js by Vaani
• 7,020 points
504 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,271 views
0 votes
1 answer
0 votes
0 answers

Upload file using NodeJS and BusBoy

I'm using NodeJS to upload a file. ...READ MORE

Jun 21, 2022 in Node-js by Vaani
• 7,020 points
1,001 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP