downloader
Contains functions for downloading large files
Functions
getContentLength(url)
— gets content length by sending HEAD request to the given url
downloader(downloadUrl, filePath, progressCallback = def() {}, bufferSize = 16384)
— downloads file from downloadUrl
to filePath
use downloader, std
MBYTES = 1048576.0 // 1024*1024
url = "http://www.ovh.net/files/10Mb.dat"
file = "10Mb.dat"
downloader(url, file, def(progress, bytesDownloaded, bytesMax) {
bar = "#" * (progress / 2)
print sprintf("%-50s %d%% %.2f / %.2f MiB\\r", bar, progress, bytesDownloaded / MBYTES, bytesMax / MBYTES)
})