I created a simple webpage using NodeJS and Socket.IO. The server needs to copy some files from a remote server to local server. I want to show this progress on the webpage, especially I want to show the file copying speed and give an estimated time. How can I do this using NodeJS?
Without seeing your relevant code, we can only offer a generic answer.
To calculate the copying file speed, you start with two initial pieces of information which you must store for future reference during the operation:
startTime).totalBytes).Then, at any point while you are copying, you can get the current system time and the amount of data copied so far and create some calculations:
var elapsedTime = currentTime - startTime;
var portionComplete = bytesCopiedSoFar / totalBytes;
var percentComplete = portionComplete * 100;
var estimatedTotalTime = (elapsedTime / bytesCopiedSoFar) * totalBytes;
var estimatedTimeRemaining = estimatedTotalTime - elapsedTime;