Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Download ¶
func Download(options DownloadOptions) error
Download downloads a file from the url in options.URL and places the content in the file at options.FilePath
Made possible with guidance from: https://golangcode.com/download-a-file-with-progress/
Types ¶
type DownloadEvent ¶
type DownloadEvent struct { State DownloadState `json:"download_state"` URL string `json:"url"` FilePath string `json:"file_path"` TempFilePath string `json:"temp_file_path"` Status *DownloadStatus `json:"status"` }
func (DownloadEvent) String ¶
func (de DownloadEvent) String() string
type DownloadOptions ¶
type DownloadState ¶
type DownloadState string
const ( DefaultEventsUpdateInterval = 500 * time.Millisecond DownloadStateStarting DownloadState = "download_starting" DownloadStateReport DownloadState = "download_report" DownloadStateError DownloadState = "download_error" DownloadStateFailed DownloadState = "download_failed" DownloadStateSuccess DownloadState = "download_success" )
type DownloadStatus ¶
type DownloadStatus struct { TotalBytes uint64 `json:"total_bytes"` ProcessedBytes uint64 `json:"processed_bytes"` }
DownloadStatus contains progress information on a Download
func (DownloadStatus) GetPercentage ¶
func (ds DownloadStatus) GetPercentage() float64
GetPercentage returns a floating point value representing the progress
Click to show internal directories.
Click to hide internal directories.