Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHTTPBlobOpener ¶
func NewHTTPBlobOpener(hostnameVerification utils.SSLHostnameVerification) func(*url.URL) (io.ReadCloser, error)
NewHTTPBlobOpener returns a blob opener func suitable for use with Download. The opener func uses an HTTP client that enforces the provided SSL hostname verification policy.
Types ¶
type Download ¶
type Download struct {
// contains filtered or unexported fields
}
Download can download a file from the network.
func StartDownload ¶
StartDownload starts a new download as specified by `req` using `openBlob` to actually pull the remote data.
func (*Download) Done ¶
Done returns a channel that receives a status when the download has completed or is aborted. Exactly one Status value will be sent for each download once it finishes (successfully or otherwise) or is aborted.
It is the receiver's responsibility to handle and remove the downloaded file.
type Downloader ¶
type Downloader struct { // OpenBlob is the func used to gain access to the blob, whether // through an HTTP request or some other means. OpenBlob func(*url.URL) (io.ReadCloser, error) }
Downloader provides the functionality for downloading files.
func (Downloader) Download ¶
func (dlr Downloader) Download(req Request) (string, error)
Download starts a new download, waits for it to complete, and returns the local name of the file. The download can be aborted by closing the Abort channel in the Request provided.
func (Downloader) Start ¶
func (dlr Downloader) Start(req Request) *Download
Start starts a new download and returns it.
type NewArgs ¶
type NewArgs struct { // HostnameVerification is that which should be used for the client. // If it is disableSSLHostnameVerification then a non-validating // client will be used. HostnameVerification utils.SSLHostnameVerification }
NewArgs holds the arguments to New().
type Request ¶
type Request struct { // URL is the location from which the file will be downloaded. URL *url.URL // TargetDir is the directory into which the file will be downloaded. // It defaults to os.TempDir(). TargetDir string // Verify is used to ensure that the download result is correct. If // the download is invalid then the func must return errors.NotValid. // If no func is provided then no verification happens. Verify func(*os.File) error // Abort is a channel that will cancel the download when it is closed. Abort <-chan struct{} }
Request holds a single download request.