1

I have an app for upload files to my server, I am using fs and stream my file to the server and use Chuck data for keep tracking file upload progress.

Here sample code for uploading:

// upload video function uploadVideo(url,file,callback) { let size = fs.lstatSync(file).size; let bytes = 0; let formData = { file: fs.createReadStream(file).on('data', (chunk) => { bytes += chunk.length process.stdout.write(file+filesize(bytes).human()+' of '+filesize(size).human()+' Uploaded'+"\r") }), }; request.post({url:url, json:true, formData: formData}, function optionalCallback(err, httpResponse, body) { if (err) { return callback('upload failed:', err); } callback(null,body); }); } 

as you can see I am using process.stdout.write for showing upload progress without newline and its work fine.

The problem I have when I am uploading multiple files same time, all upload progress get override in one line, I want each upload progress be in separate line.

Multiple upload example:

let files = ['video-1.mp4','video-2.mp4','video-3.mp4','video-4.mp4','video-5.mp4'] // upload multiple file files.forEach((file) => { uploadVideo(url,file,function(err,output){ console.log(output) }) }) 
0

2 Answers 2

1

There is a package for that: node-progress

It gives you something like this:

downloading [===== ] 39/bps 29% 3.7s 
Sign up to request clarification or add additional context in comments.

1 Comment

I tested this, still, same problem here is a demo , its show all progress bar in one line.
0

I found a package called multi-progress multi-progress. it does exactly what I want.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.