NodeJs file transfer progress bar

I want to use node to transfer files to other servers
has been implemented
using request or axios libraries, but I want to get the progress of the transfer
what should I do?

// request
let form = {
    type:"zip",
    file:file,
    path:"/temp"
}

request.post({
    url:url,
    formData:form
},(err,res,body)=>{
    if(err){
        console.log(err)
        return
    }
    console.log(body)
    console.log("")
})
// axios
let fd = new FormData();
fd.append("type","zip")
fd.append("file", file)
function getHeaders(form) {
    return new Promise((resolve, reject) => {
    form.getLength((err, length) => {
    if(err) { reject(err); }
        let headers = Object.assign({"Content-Length": length}, form.getHeaders());
        resolve(headers);
        });
    });
}
getHeaders(fd)
.then(function(headers){
    axios.post(url, fd, {
        headers:headers,
        onUploadProgress:function(e){
            console.log("0")
        }
    }).then(function(res){
        console.log("")
    })
})
Mar.11,2021

1. The progress is not the same as the progress bar.
2. The progress bar belongs to the css style, and you can use js to dynamically implement the css progress bar, which is needless to say.
3. As far as I know, the progress is (accepted file size) / (full file size)

Menu