store

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STORE_ALIYUN  = "aliyun"
	STORE_TENCENT = "tencent"
	STORE_LOCAL   = "local"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Endpoint        string
	Id              string
	Secret          string
	Bucket          string
	DB              *gorm.DB
	Cache           *redis.Client
	LocalDir        string
	ServerURL       string
	TemporaryExpire time.Duration
}

type PutChunk

type PutChunk interface {
	// UploadedChunkIndex 已经上传的切片下标
	UploadedChunkIndex() []uint32

	// ChunkCount 查询切片数量
	ChunkCount() int

	// UploadID 获取上传id
	UploadID() string

	// AppendBytes 添加字节
	AppendBytes(in []byte, index int) error

	// Append 添加io
	Append(r io.Reader, index int) error

	// Abort 取消上传
	Abort() error

	// Complete 完成合并
	Complete() error
}

type Store

type Store interface {
	// GenTemporaryURL 生成临时访问路径
	GenTemporaryURL(key string) (string, error)

	// VerifyTemporaryURL 验证临时url
	VerifyTemporaryURL(key string, expire string, sign string) error

	// PutBytes 上传文件
	PutBytes(key string, in []byte) error

	// Put 上传文件
	Put(key string, r io.Reader) error

	// PutFromLocal 从本地上传文件
	PutFromLocal(key string, localPath string) error

	// Get 查询文件
	Get(key string) (io.ReadCloser, error)

	// Delete 删除文件
	Delete(key string) error

	// Size 获取文件大小
	Size(key string) (int64, error)

	// Exists 判断文件大小
	Exists(key string) (bool, error)

	// NewPutChunk 创建上传切片对象
	NewPutChunk(key string) (PutChunk, error)

	// NewPutChunkByUploadID 通过upload_id创建切片对象
	NewPutChunkByUploadID(key string, id string) (PutChunk, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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