godownload

package module
v0.0.0-...-3f14bc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2019 License: MIT Imports: 16 Imported by: 0

README

godownload

Codacy Badge Build Status Go Report Card

Downloading files

Install
go get https://github.com/saromanov/godownload
Usage

Download file

package main
import "github.com/saromanov/godownload"

func main() { 
    godownload.Download("http://arxiv.org/pdf/1206.5538v3.pdf", nil)
}

Download with set output file

godownload.Download("http://arxiv.org/pdf/1206.5538v3.pdf", &godownload.Options{Outpath: "fun.pdf"})

If you have a links on the file, you can download data by this links

download.FromFile("file")
API

godownload.Options

Url - Url parameter needs only for DownloadMany. In the case with Download. This paremeter will be ignore

Outpath - Outpath sets the path of the downloaded file

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoDownload

type GoDownload struct {

	//Overwrite provides overwriting file with same name
	Overwrite bool

	//Always create new file. If file with same name exist
	// create "file_1"
	Alwaysnew bool

	//UserAgent provides setting user agent for http request
	UserAgent string

	//Retry provides number of attempts to download file
	Retry int

	//Authentication before downloading. Auth in the format username:password
	Auth string

	//Specify archive format for downloaded file
	Archive string

	//Path to the config file
	Configpath string

	//Directory for downloaded file
	Outdir string
}

GoDownload provides main struct for global config and downloading items

func (*GoDownload) Download

func (gd *GoDownload) Download(path string, opt *Options)

Download provides downloading of file

func (*GoDownload) DownloadMany

func (gd *GoDownload) DownloadMany(items []*Options)

DownloadMany provides downloading several files

func (*GoDownload) DownloadManySimple

func (gd *GoDownload) DownloadManySimple(items []string)

DownloadManySimple is identical for DownloadMany, but as arguments is slice of url

func (*GoDownload) FromFile

func (gd *GoDownload) FromFile(path string)

FromFile provides getting links from file and download

type Options

type Options struct {

	// URL parameter needs only for DownloadMany.
	// In the case with Download. This paremeter will be ignore
	URL string

	//Download web page instead file
	Page bool

	//Outpath sets the path of the downloaded file
	Outpath string

	//Overwrite provides overwriting file with same name
	Overwrite bool

	//Always create new file. If file with same name exist
	// create "file_1"
	Alwaysnew bool

	//UserAgent provides setting user agent for http request
	UserAgent string

	//Retry provides number of attempts to download file
	Retry int

	//Authentication before downloading. Auth in the format username:password
	Auth string

	//Specify archive format for downloaded file
	Archive string

	//TODO
	TimeLimit time.Time
}

Options defines attributes for config of GoDownload

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL