oss_client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListObjectsResult

type ListObjectsResult struct {
	Prefix         string             `json:"prefix"`
	Marker         string             `json:"marker"`
	Delimiter      string             `json:"delimiter"`
	IsTruncated    bool               `json:"is_truncated"`
	NextMarker     string             `json:"next_marker"`
	Objects        []ObjectProperties `json:"objects"`
	CommonPrefixes []string           `json:"common_prefixes"`
}

type ObjectMeta

type ObjectMeta struct {
	Hash     string `json:"hash"`      // 文件hash
	FileSize int64  `json:"file_size"` // 文件大小
	PutTime  int64  `json:"putTime"`   // 上传时间
	Type     int    `json:"type"`      // 类型
}

type ObjectProperties

type ObjectProperties struct {
	Key  string `json:"key"`  // Object key
	Type string `json:"type"` // Object type
	Size int64  `json:"size"` // Object size
	ETag string `json:"etag"` // Object etag
}

type Option

type Option func(o *Options)

func ContentType

func ContentType(contentType string) Option

ContentType 设置类型

func Delimiter

func Delimiter(delimiter string) Option

Delimiter 过滤

func IsPrivate

func IsPrivate(isPrivate bool) Option

IsPrivate 是否私有

func Limit

func Limit(limit int) Option

Limit 限定列表大小

func Marker

func Marker(marker string) Option

Marker 标记

func Prefix

func Prefix(prefix string) Option

Prefix 设置前缀

func Process

func Process(listener ProgressListener) Option

Process 设置进度

func SessionToken

func SessionToken(token string) Option

SessionToken 临时token

func TokenExpiry

func TokenExpiry(expiry int) Option

TokenExpiry token过期时间

type Options

type Options struct {
	IsPrivate    bool             //  是否私有
	ContentType  string           // 类型
	Process      ProgressListener // 进度
	Prefix       string           // 前缀
	Marker       string           // 标记
	Delimiter    string           // 目录过滤
	Limit        int              // 限制列表大小
	TokenExpiry  int              // token过期时间
	SessionToken string           // 临时token
}

Options oss的参数选项

func ForOption

func ForOption(opts ...Option) Options

type OssClientIface

type OssClientIface interface {
	// Token 获取token
	Token(ctx context.Context, bucket string, objectKey string, opts ...Option) (*Token, error)
	// ObjectMeta 获取对象基本信息
	ObjectMeta(ctx context.Context, bucket string, objectKey string, opts ...Option) (*ObjectMeta, error)
	// PutObject 上传对象
	PutObject(ctx context.Context, bucket string, objectKey string, data io.Reader, size int64, opts ...Option) (string, error)
	// PutObjectFromFile 从本地文件上传对象
	PutObjectFromFile(ctx context.Context, bucket string, objectKey string, filePath string, opts ...Option) (string, error)
	// BatchCopy 批量复制
	BatchCopy(ctx context.Context, bucket string, copyKeys map[string]string, opts ...Option) error
	// GetObject 获取对象
	GetObject(ctx context.Context, bucket string, objectKey string, opts ...Option) ([]byte, error)
	// Copy 复制对象
	Copy(ctx context.Context, bucket string, srcObject string, dstObject string, opts ...Option) error
	// ListObjects 获取对象信息列表
	ListObjects(ctx context.Context, bucket string, opts ...Option) (ListObjectsResult, error)
	// MakePrivateURL 创建私有URL
	MakePrivateURL(ctx context.Context, bucket string, key string, deadline int64, opts ...Option) (string, error)
}

OssClientIface oss客户端

func NewAliClient

func NewAliClient(opts OssConfig) OssClientIface

func NewMinioClient

func NewMinioClient(opts OssConfig) OssClientIface

func NewQiniuClient

func NewQiniuClient(opts OssConfig) OssClientIface

type OssConfig

type OssConfig struct {
	AccessKey       string // key
	AccessSecret    string // 密钥
	Endpoint        string // 端点
	DownloadUrl     string // 下载地址
	RoleArn         string // 角色
	RoleSessionName string // 角色名称
	RegionId        string // 区域
}

type ProgressEvent

type ProgressEvent struct {
	ConsumedBytes int64
	TotalBytes    int64
}

ProgressEvent defines progress event

type ProgressListener

type ProgressListener interface {
	ProgressChanged(event *ProgressEvent)
}

ProgressListener listens progress change

type Token

type Token struct {
	Token           string `json:"token"`             // token信息
	AccessKey       string `json:"access_key"`        // key
	AccessKeySecret string `json:"access_key_secret"` // 密钥
	Expiration      int64  `json:"expiration"`        // 到期时间,时间戳
	Bucket          string `json:"bucket"`            // bucket
	Endpoint        string `json:"endpoint"`          // 端点
}

Jump to

Keyboard shortcuts

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