Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultSegmentSize = 10 * 1024 * 1024
DefaultSegmentSize stands for the default segment size (10 Mb)
if the segment size is not set, the default segment size is used
Functions ¶
Types ¶
type Config ¶
type Config struct {
// FileName
FilePath string
// SegmentSize
SegmentSize int
// TmpDir
TmpDir string
//
IsRangesDisabled bool
}
Config represents the download config
type Downloader ¶
type Downloader struct {
// URL is the url to download
URL string
// FileDir represents the directory to store the downloaded file
FileDir string
// FileName represents the file name
FileName string
// FileExt represents the file extension
FileExt string
// HeadHeaders represents the headers of the head file response
HeadHeaders http.Header
// ContentType represents the content type of the file
ContentType string
// ContentLength represents the content length of the file
ContentLength int64
// Hash represents the file info hash, use for temp dir
Hash string
// IsSupportRange represents if the server supports the range header
IsSupportRange bool
// SegmentSize represents the size of each segment, default is 10 Mb
SegmentSize int
// Ranges represents the ranges of the file
Ranges []*Range
// FileParts represents the file parts by ranges
FileParts []*FilePart
// TmpDir represents the temporary directory to store file parts
TmpDir string
//
IsRangesDisabled bool
}
Downloader is the downloader
type FilePart ¶
type FilePart struct {
// Name of the file.
// format <file_name>.<file_ext>.part.<part_index>.<range_start>.<range_end>
Name string
// FilePath concats the TmpDir and Hash.
Path string
//
FileName string
FileExt string
Index int
RangeStart int
RangeEnd int
}
FilePart represents a part of a file. Format: <file_name>.<file_ext>.part.<part_index>.<range_start>.<range_end>
Click to show internal directories.
Click to hide internal directories.