Upload file using NodeJS and BusBoy

0 votes

I'm using NodeJS to upload a file. My goal is to read the stream into a variable, which I can then save in AWS SQS. I don't want the file to be saved to disc. Is that even possible? I only require the streaming of the uploaded file. (upload.js) is the code I'm using:

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 can I retrieve the stream that was uploaded?

Jun 21, 2022 in Node-js by Vaani
• 7,070 points
1,916 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,880 points
9,455 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
• 9,020 points
822 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
• 9,020 points
1,592 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,070 points
705 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
• 9,020 points
7,554 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,070 points
950 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,901 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,424 views
0 votes
0 answers

Upload file using NodeJS and BusBoy

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

Jun 22, 2022 in Node-js by Vaani
• 7,070 points
3,347 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