github.com/qiniu/go-sdk/v7@v7.27.0/storagev2/downloader/interfaces.go (about)

     1  package downloader
     2  
     3  import (
     4  	"context"
     5  	"net/http"
     6  	"net/url"
     7  	"time"
     8  
     9  	"github.com/qiniu/go-sdk/v7/storagev2/downloader/destination"
    10  )
    11  
    12  type (
    13  	// 获取 URL 迭代器
    14  	URLsIter interface {
    15  		// 获取首个 URL
    16  		Peek(*url.URL) (bool, error)
    17  		// 切换到下一个 URL
    18  		Next()
    19  		// 重置迭代器
    20  		Reset()
    21  		// 复制迭代器
    22  		Clone() URLsIter
    23  	}
    24  
    25  	// 获取对象下载 URL 接口
    26  	DownloadURLsProvider interface {
    27  		GetURLsIter(context.Context, string, *GenerateOptions) (URLsIter, error)
    28  	}
    29  
    30  	// 对下载 URL 签名
    31  	Signer interface {
    32  		Sign(context.Context, *url.URL, *SignOptions) error
    33  	}
    34  
    35  	// 下载进度
    36  	DownloadingProgress struct {
    37  		Downloaded uint64 // 已经下载的数据量,单位为字节
    38  		TotalSize  uint64 // 总数据量,单位为字节
    39  	}
    40  
    41  	// 目标下载选项
    42  	DestinationDownloadOptions struct {
    43  		// 对象下载附加 HTTP Header
    44  		Header http.Header
    45  		// 对象下载进度
    46  		OnDownloadingProgress func(*DownloadingProgress)
    47  		// 对象 Header 获取回调
    48  		OnResponseHeader func(http.Header)
    49  	}
    50  
    51  	// 目标下载器
    52  	DestinationDownloader interface {
    53  		Download(context.Context, URLsIter, destination.Destination, *DestinationDownloadOptions) (uint64, error)
    54  	}
    55  
    56  	// 对象下载 URL 生成选项
    57  	GenerateOptions struct {
    58  		// 空间名称,可选
    59  		BucketName string
    60  
    61  		// 文件处理命令,可选
    62  		Command string
    63  
    64  		// 是否使用 HTTP 协议,默认为不使用
    65  		UseInsecureProtocol bool
    66  	}
    67  
    68  	// 对象签名选项
    69  	SignOptions struct {
    70  		// 签名有效期,如果不填写,默认为 3 分钟
    71  		TTL time.Duration
    72  	}
    73  )