Example #1
0
func DownloadFile(url string, fileName string, verbose bool) {
	req := curl.New(url)

	req.Method("POST")
	req.SaveToFile(fileName)

	// Print progress status per one second
	req.Progress(func(p curl.ProgressStatus) {
		if verbose {
			log.SetOutput(os.Stdout)
			log.Println(
				"speed", curl.PrettySpeedString(p.Speed),
				"len", curl.PrettySizeString(p.ContentLength),
				"got", curl.PrettySizeString(p.Size),
			)
		}
	}, time.Second)

	req.Do()
}
func (d *DownloadableFile) SetSource(url string) {
	d.Request = curl.New(url)
}