Download a file with multiple connections and multiple sources simultaneously.
# Build the executable
make
# Install as library
go get github.com/alvatar/multipart-downloader
godl [flags ...] [urls ...]
Flags:
-n Number of concurrent connections
-S A SHA-256 string to check the downloaded file
-E Verify using Etag as MD5
-t Timeout for all connections in milliseconds (default 5000)
-o Output file
-v Verbose output, show progress bars
urls := []string{
"https://raw.githubusercontent.com/alvatar/multipart-downloader/master/test/quijote.txt",
"https://raw.githubusercontent.com/alvatar/multipart-downloader/master/test/quijote2.txt",}
nConns := 2
timeout := time.Duration(5000) * time.Millisecond
dldr := md.NewMultiDownloader(urls, nConns, timeout)
// Gather info from all sources
_, err := dldr.GatherInfo()
// Prepare the file to write downloaded blocks on it
_, err = dldr.SetupFile(*output)
// Perform download
err = dldr.Download(func(feedback []md.ConnectionProgress) {
log.Println(feedback)
})
err = dldr.CheckSHA256("1e9bb1b16f8810e44d6d5ede7005258518fa976719bc2ed254308e73c357cfcc")
err = dldr.CheckMD5("45bb5fc96bb4c67778d288fba98eee48")