Documentation ¶
Index ¶
- type DirectoryOptions
- type FormUploaderOptions
- type InitializedParts
- type MultiPartsObjectOptions
- type MultiPartsUploader
- type MultiPartsUploaderOptions
- type MultiPartsUploaderVersion
- type ObjectOptions
- type UploadManager
- func (uploadManager *UploadManager) UploadDirectory(ctx context.Context, directoryPath string, directoryOptions *DirectoryOptions) error
- func (uploadManager *UploadManager) UploadFile(ctx context.Context, path string, objectOptions *ObjectOptions, ...) error
- func (uploadManager *UploadManager) UploadReader(ctx context.Context, reader io.Reader, objectOptions *ObjectOptions, ...) error
- type UploadManagerOptions
- type UploadPartOptions
- type UploadPartsOptions
- type UploadedObjectInfo
- type UploadedPart
- type Uploader
- type UploadingPartProgress
- type UploadingProgress
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirectoryOptions ¶
type DirectoryOptions struct { // 区域提供者 RegionsProvider region.RegionsProvider // 上传凭证 UpToken uptoken.Provider // 空间名称 BucketName string // 上传并发度 ObjectConcurrency int // 上传前回调函数 BeforeObjectUpload func(filePath string, objectOptions *ObjectOptions) // 上传进度 OnUploadingProgress func(filePath string, progress *UploadingProgress) // 对象上传成功后回调 OnObjectUploaded func(filePath string, info *UploadedObjectInfo) // 是否在空间内创建目录 ShouldCreateDirectory bool // 是否上传指定对象,如果 objectOptions 为 nil 则表示是目录 ShouldUploadObject func(filePath string, objectOptions *ObjectOptions) bool // 更改对象名称 UpdateObjectName func(string) string // 分隔符,默认为 / PathSeparator string }
type FormUploaderOptions ¶
type FormUploaderOptions struct { httpclient.Options // 上传凭证 UpToken uptoken.Provider }
表单上传器选项
type InitializedParts ¶
经过初始化的分片上传
type MultiPartsObjectOptions ¶
type MultiPartsObjectOptions struct { // 对象上传选项 ObjectOptions // 分片大小,如果不填写,默认为 4 MB PartSize uint64 }
分片上传对象上传选项
type MultiPartsUploader ¶
type MultiPartsUploader interface { // 初始化分片上传 InitializeParts(context.Context, source.Source, *MultiPartsObjectOptions) (InitializedParts, error) // 尝试恢复分片,如果返回 nil 表示恢复失败 TryToResume(context.Context, source.Source, *MultiPartsObjectOptions) InitializedParts // 上传分片 UploadPart(context.Context, InitializedParts, source.Part, *UploadPartOptions) (UploadedPart, error) // 完成分片上传,生成对象 CompleteParts(context.Context, InitializedParts, []UploadedPart, interface{}) error // 获取分片上传选项 MultiPartsUploaderOptions() *MultiPartsUploaderOptions }
分片上传器接口
func NewMultiPartsUploaderV1 ¶
func NewMultiPartsUploaderV1(options *MultiPartsUploaderOptions) MultiPartsUploader
创建分片上传器 V1
func NewMultiPartsUploaderV2 ¶
func NewMultiPartsUploaderV2(options *MultiPartsUploaderOptions) MultiPartsUploader
创建分片上传器 V2
type MultiPartsUploaderOptions ¶
type MultiPartsUploaderOptions struct { // HTTP 客户端选项 httpclient.Options // 上传凭证接口 UpTokenProvider uptoken.Provider // 可恢复记录,如果不设置,则无法进行断点续传 ResumableRecorder resumablerecorder.ResumableRecorder }
分片上传器选项
type MultiPartsUploaderVersion ¶
type MultiPartsUploaderVersion uint8
分片上传版本
const ( // 分片上传 V1 MultiPartsUploaderVersionV1 MultiPartsUploaderVersion = 1 // 分片上传 V2 MultiPartsUploaderVersionV2 MultiPartsUploaderVersion = 2 )
type ObjectOptions ¶
type ObjectOptions struct { // 区域提供者,可选 RegionsProvider region.RegionsProvider // 上传凭证接口,可选 // 但如果不传值,则必须给出 BucketName,并且配合 Uploader 的 Credentials 自动生成 UpToken UpToken uptoken.Provider // 空间名称,可选,但如果不传值,则必须给出 UpToken BucketName string // 对象名称 ObjectName *string // 文件名称 FileName string // 文件 MIME 类型 ContentType string // 自定义元数据 Metadata map[string]string // 自定义变量 CustomVars map[string]string // 对象上传进度 OnUploadingProgress func(*UploadingProgress) }
对象上传选项
type UploadManager ¶
type UploadManager struct {
// contains filtered or unexported fields
}
上传器
func (*UploadManager) UploadDirectory ¶
func (uploadManager *UploadManager) UploadDirectory(ctx context.Context, directoryPath string, directoryOptions *DirectoryOptions) error
上传目录
func (*UploadManager) UploadFile ¶
func (uploadManager *UploadManager) UploadFile(ctx context.Context, path string, objectOptions *ObjectOptions, returnValue interface{}) error
上传文件
func (*UploadManager) UploadReader ¶
func (uploadManager *UploadManager) UploadReader(ctx context.Context, reader io.Reader, objectOptions *ObjectOptions, returnValue interface{}) error
上传 io.Reader
type UploadManagerOptions ¶
type UploadManagerOptions struct { // HTTP 客户端选项 httpclient.Options // 上传凭证接口 UpTokenProvider uptoken.Provider // 可恢复记录,如果不设置,则无法进行断点续传 ResumableRecorder resumablerecorder.ResumableRecorder // 分片大小,如果不填写,默认为 4 MB PartSize uint64 // 分片上传阈值,如果不填写,默认为 4 MB MultiPartsThreshold uint64 // 分片上传并行度,如果不填写,默认为 1 Concurrency int // 分片上传版本,如果不填写,默认为 V2 MultiPartsUploaderVersion MultiPartsUploaderVersion }
上传器选项
type UploadPartOptions ¶
type UploadPartOptions struct { // 分片上传进度 OnUploadingProgress func(*UploadingPartProgress) }
上传分片选项
type UploadPartsOptions ¶
type UploadPartsOptions struct { // 分片上传进度 OnUploadingProgress func(partNumber uint64, progress *UploadingPartProgress) // 分片上传成功后回调函数 OnPartUploaded func(UploadedPart) error }
上传分片列表选项
type UploadedPart ¶
type UploadedPart interface { // 分片编号 PartNumber() uint64 // 分片偏移量 Offset() uint64 // 分片大小 PartSize() uint64 }
已经上传的分片
type Uploader ¶
type Uploader interface { // 上传文件 UploadFile(context.Context, string, *ObjectOptions, interface{}) error // 上传 io.Reader UploadReader(context.Context, io.Reader, *ObjectOptions, interface{}) error }
上传对象接口
type UploadingPartProgress ¶
type UploadingPartProgress struct { Uploaded uint64 // 已经上传的数据量,单位为字节 PartSize uint64 // 分片大小,单位为字节 }
分片上传进度
type UploadingProgress ¶
对象上传进度
Source Files ¶
Click to show internal directories.
Click to hide internal directories.