object

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package object object/copy.go

Package object object/delete.go

Package object object/errors.go

Package object object/get.go

Package object object/list.go

Package object object/multipart.go

Package object object/object.go

Package object object/options.go

Package object object/put.go

Package object object/service.go

Package object object/stat.go

Package object object/utils.go

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidBucketName 无效的桶名
	ErrInvalidBucketName = errors.New("invalid bucket name")

	// ErrInvalidObjectName 无效的对象名
	ErrInvalidObjectName = errors.New("invalid object name")

	// ErrObjectNotFound 对象不存在
	ErrObjectNotFound = errors.New("object not found")

	// ErrNotImplemented 功能未实现
	ErrNotImplemented = errors.New("not implemented yet")
)

Functions

func WithVersionID

func WithVersionID(versionID string) interface{}

WithVersionID 设置版本 ID(用于 Get/Stat/Delete)

Types

type CommonPrefix

type CommonPrefix struct {
	Prefix string `xml:"Prefix"`
}

CommonPrefix 公共前缀

type CopyOption

type CopyOption func(*CopyOptions)

CopyOption 复制选项函数

func WithCopyMetadata

func WithCopyMetadata(metadata map[string]string, replace bool) CopyOption

WithCopyMetadata 设置复制元数据

func WithCopySourceVersionID

func WithCopySourceVersionID(versionID string) CopyOption

WithCopySourceVersionID 设置源版本 ID

type CopyOptions

type CopyOptions struct {
	// 源版本 ID
	SourceVersionID string

	// 目标元数据
	UserMetadata map[string]string
	UserTags     map[string]string

	// 替换元数据
	ReplaceMetadata bool
	ReplaceTagging  bool

	// 内容类型
	ContentType        string
	ContentEncoding    string
	ContentDisposition string
	CacheControl       string
	Expires            time.Time

	// 存储类
	StorageClass string

	// 匹配条件
	MatchETag     string
	NotMatchETag  string
	MatchModified time.Time
	NotModified   time.Time

	// 自定义头
	CustomHeaders http.Header
}

CopyOptions 复制选项

type DeleteOption

type DeleteOption func(*DeleteOptions)

DeleteOption 删除选项函数

type DeleteOptions

type DeleteOptions struct {
	// 版本 ID
	VersionID string

	// 强制删除
	ForceDelete bool

	// 自定义头
	CustomHeaders http.Header
}

DeleteOptions 删除选项

type GetOption

type GetOption func(*GetOptions)

GetOption 下载选项函数

func WithGetRange

func WithGetRange(start, end int64) GetOption

WithGetRange 设置下载范围

type GetOptions

type GetOptions struct {
	// Range 请求范围
	RangeStart int64
	RangeEnd   int64
	SetRange   bool

	// 版本 ID
	VersionID string

	// 匹配条件
	MatchETag     string
	NotMatchETag  string
	MatchModified time.Time
	NotModified   time.Time

	// 自定义头
	CustomHeaders http.Header
}

GetOptions 下载选项

type ListBucketV2Result

type ListBucketV2Result struct {
	XMLName               xml.Name           `xml:"ListBucketResult"`
	Name                  string             `xml:"Name"`
	Prefix                string             `xml:"Prefix"`
	KeyCount              int                `xml:"KeyCount"`
	MaxKeys               int                `xml:"MaxKeys"`
	Delimiter             string             `xml:"Delimiter"`
	IsTruncated           bool               `xml:"IsTruncated"`
	Contents              []types.ObjectInfo `xml:"Contents"`
	CommonPrefixes        []CommonPrefix     `xml:"CommonPrefixes"`
	ContinuationToken     string             `xml:"ContinuationToken"`
	NextContinuationToken string             `xml:"NextContinuationToken"`
	StartAfter            string             `xml:"StartAfter"`
}

ListBucketV2Result 列出存储桶 V2 响应结果

type ListOption

type ListOption func(*ListOptions)

ListOption 列出对象选项函数

func WithListMaxKeys

func WithListMaxKeys(maxKeys int) ListOption

WithListMaxKeys 设置最大键数

func WithListPrefix

func WithListPrefix(prefix string) ListOption

WithListPrefix 设置列出前缀

func WithListRecursive

func WithListRecursive(recursive bool) ListOption

WithListRecursive 设置递归列出

type ListOptions

type ListOptions struct {
	// 前缀
	Prefix string

	// 递归列出
	Recursive bool

	// 最大键数
	MaxKeys int

	// 起始位置
	StartAfter string

	// 使用 V2 API
	UseV2 bool

	// 包含版本
	WithVersions bool

	// 包含元数据
	WithMetadata bool

	// 自定义头
	CustomHeaders http.Header
}

ListOptions 列出对象选项

type PutOption

type PutOption func(*PutOptions)

PutOption 上传选项函数

func WithContentDisposition

func WithContentDisposition(disposition string) PutOption

WithContentDisposition 设置内容处置

func WithContentEncoding

func WithContentEncoding(encoding string) PutOption

WithContentEncoding 设置内容编码

func WithContentType

func WithContentType(contentType string) PutOption

WithContentType 设置内容类型

func WithPartSize

func WithPartSize(size uint64) PutOption

WithPartSize 设置分片大小

func WithStorageClass

func WithStorageClass(class string) PutOption

WithStorageClass 设置存储类

func WithUserMetadata

func WithUserMetadata(metadata map[string]string) PutOption

WithUserMetadata 设置用户元数据

func WithUserTags

func WithUserTags(tags map[string]string) PutOption

WithUserTags 设置用户标签

type PutOptions

type PutOptions struct {
	// 内容类型
	ContentType string

	// 内容编码
	ContentEncoding string

	// 内容处置
	ContentDisposition string

	// 内容语言
	ContentLanguage string

	// 缓存控制
	CacheControl string

	// 过期时间
	Expires time.Time

	// 用户元数据
	UserMetadata map[string]string

	// 用户标签
	UserTags map[string]string

	// 存储类
	StorageClass string

	// 自定义头
	CustomHeaders http.Header

	// 发送 Content-MD5
	SendContentMD5 bool

	// 禁用 Content-SHA256
	DisableContentSHA256 bool

	// 分片大小
	PartSize uint64

	// 并发数
	NumThreads uint
}

PutOptions 上传选项

type Service

type Service interface {
	// Put 上传对象
	Put(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64, opts ...PutOption) (types.UploadInfo, error)

	// Get 下载对象
	Get(ctx context.Context, bucketName, objectName string, opts ...GetOption) (io.ReadCloser, types.ObjectInfo, error)

	// Stat 获取对象信息
	Stat(ctx context.Context, bucketName, objectName string, opts ...StatOption) (types.ObjectInfo, error)

	// Delete 删除对象
	Delete(ctx context.Context, bucketName, objectName string, opts ...DeleteOption) error

	// List 列出对象
	List(ctx context.Context, bucketName string, opts ...ListOption) <-chan types.ObjectInfo

	// Copy 复制对象
	Copy(ctx context.Context, destBucket, destObject, srcBucket, srcObject string, opts ...CopyOption) (types.CopyInfo, error)
}

Service Object 服务接口

func NewService

func NewService(executor *core.Executor, locationCache *cache.LocationCache) Service

NewService 创建 Object 服务

type StatOption

type StatOption func(*StatOptions)

StatOption 获取对象信息选项函数

type StatOptions

type StatOptions struct {
	// 版本 ID
	VersionID string

	// 自定义头
	CustomHeaders http.Header
}

StatOptions 获取对象信息选项

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL