Speed and ETA
Display real-time upload speed (KB/s or MB/s) and estimated time remaining for each file.
What you should see: live transfer speed and a time-remaining estimate per file, both derived from progress events. Throttle your connection to watch the estimate adjust. Cap is 100 MB.
Ready
<div id="my-uploader"></div>
<span id="speed"></span>
<span id="eta"></span>
<script>
var startTime, startLoaded;
CoreUpload.create('#my-uploader', {
uploadUrl: '/api/upload/upload',
autoUpload: true,
maxFileSize: '100MB',
// The engine maintains task.speed (bytes/sec, smoothed) and task.eta
// (seconds) for you - no need to time the transfer by hand.
onTaskProgress: function(task) {
var speedText = task.speed > 1048576
? (task.speed / 1048576).toFixed(1) + ' MB/s'
: (task.speed / 1024).toFixed(0) + ' KB/s';
var etaText = task.eta < 60
? Math.ceil(task.eta) + 's remaining'
: Math.ceil(task.eta / 60) + 'm remaining';
document.getElementById('speed').textContent = speedText;
document.getElementById('eta').textContent = etaText;
},
onTaskComplete: function(task) {
document.getElementById('speed').textContent = 'Done';
document.getElementById('eta').textContent = '';
}
});
</script> Rate and time remaining
Both come from progress events: bytes over elapsed time gives a rate, and remaining bytes divided by that rate gives an estimate. Neither is reported by the server — they are derived entirely from what the browser has managed to send.
Smooth it or it is unreadable
An instantaneous rate swings with every chunk and every scheduling hiccup, and an ETA built from it jumps between twenty seconds and four minutes. A rolling average over a few seconds is what makes both usable — an ETA that constantly changes direction is worse than none.