file_storage

package module
v0.0.0-...-e7b1bb4 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

README

file-storage

易用聚合的文件上传 go sdk

Documentation

Index

Constants

View Source
const (
	Local   = "Local"
	Minio   = "Minio"
	AliYun  = "OSS"
	Tencent = "COS"
	QiNiu   = "QiNiu"
	HuaWei  = "OBS"
)

Variables

View Source
var (
	NotDirErr = errors.New(`"dirPath\" should be a directory path`)
)

Functions

This section is empty.

Types

type IUpload

type IUpload interface {
	Upload(ctx context.Context, file *multipart.FileHeader, randomly bool) (path, fileUrl string, err error)
	// MultipartUpload
	//chunkSize 单位byte
	MultipartUpload(ctx context.Context, file *multipart.FileHeader, randomly bool, chunkSize int) (path, fileUrl string, err error)
	GetUploaderType() string
	DeleteObjects(ctx context.Context, path []string) error
}

type UploadResult

type UploadResult struct {
	Driver   string
	FileName string
	Path     string
	Size     string
	FileUrl  string
	Ext      string
}

type Uploader

type Uploader struct {
	// contains filtered or unexported fields
}

func NewFileUploader

func NewFileUploader() *Uploader

func (*Uploader) DeleteObjects

func (u *Uploader) DeleteObjects(ctx context.Context, path []string) error

func (*Uploader) MultipartUpload

func (u *Uploader) MultipartUpload(ctx context.Context, file *multipart.FileHeader, randomName bool, chunkSize int) (res UploadResult, err error)

func (*Uploader) RegisterUploader

func (u *Uploader) RegisterUploader(uploader IUpload) *Uploader

func (*Uploader) SetLevel

func (u *Uploader) SetLevel(level zapcore.Level) *Uploader

func (*Uploader) SetLogName

func (u *Uploader) SetLogName(appName string) *Uploader

func (*Uploader) SetOutputPath

func (u *Uploader) SetOutputPath(path string) *Uploader

func (*Uploader) Upload

func (u *Uploader) Upload(ctx context.Context, file *multipart.FileHeader, randomName bool) (res UploadResult, err error)

type UploaderCos

type UploaderCos struct {
	// contains filtered or unexported fields
}

func NewUploaderCos

func NewUploaderCos(config UploaderCosConfig) (uploader *UploaderCos, err error)

func (*UploaderCos) DeleteObjects

func (u *UploaderCos) DeleteObjects(ctx context.Context, path []string) error

func (*UploaderCos) GetUploaderType

func (u *UploaderCos) GetUploaderType() string

func (*UploaderCos) MultipartUpload

func (u *UploaderCos) MultipartUpload(ctx context.Context, file *multipart.FileHeader, randomly bool, chunkSize int) (path, fileUrl string, err error)

func (*UploaderCos) Upload

func (u *UploaderCos) Upload(ctx context.Context, file *multipart.FileHeader, randomly bool) (path, fileUrl string, err error)

type UploaderCosConfig

type UploaderCosConfig struct {
	AccessKeyID     string
	SecretAccessKey string
	EndPoint        string
	BucketName      string
	Path            string
	Domain          string
	Region          string
}

type UploaderLocal

type UploaderLocal struct {
	// contains filtered or unexported fields
}

func NewUploaderLocal

func NewUploaderLocal(config UploaderLocalConfig) (uploader *UploaderLocal, err error)

func (*UploaderLocal) DeleteObjects

func (u *UploaderLocal) DeleteObjects(ctx context.Context, path []string) error

func (*UploaderLocal) GetUploaderType

func (u *UploaderLocal) GetUploaderType() string

func (*UploaderLocal) MultipartUpload

func (u *UploaderLocal) MultipartUpload(ctx context.Context, file *multipart.FileHeader, randomly bool, chunkSize int) (path, fileUrl string, err error)

func (*UploaderLocal) Upload

func (u *UploaderLocal) Upload(ctx context.Context, file *multipart.FileHeader, randomly bool) (path, fileUrl string, err error)

type UploaderLocalConfig

type UploaderLocalConfig struct {
	LocalPath string
	Domain    string
}

type UploaderMinio

type UploaderMinio struct {
	// contains filtered or unexported fields
}

func NewUploaderMinio

func NewUploaderMinio(config UploaderMinioConfig) (uploader *UploaderMinio, err error)

func (*UploaderMinio) DeleteObjects

func (u *UploaderMinio) DeleteObjects(ctx context.Context, path []string) error

func (*UploaderMinio) GetUploaderType

func (u *UploaderMinio) GetUploaderType() string

func (*UploaderMinio) MultipartUpload

func (u *UploaderMinio) MultipartUpload(ctx context.Context, file *multipart.FileHeader, randomly bool, chunkSize int) (path, fileUrl string, err error)

func (*UploaderMinio) Upload

func (u *UploaderMinio) Upload(ctx context.Context, file *multipart.FileHeader, randomly bool) (path, fileUrl string, err error)

type UploaderMinioConfig

type UploaderMinioConfig struct {
	AccessKeyID     string
	SecretAccessKey string
	EndPoint        string
	BucketName      string
	Path            string
	UseSSL          bool
	Domain          string
}

type UploaderObs

type UploaderObs struct {
	// contains filtered or unexported fields
}

func NewUploaderObs

func NewUploaderObs(config UploaderObsConfig) (uploader *UploaderObs, err error)

func (*UploaderObs) DeleteObjects

func (u *UploaderObs) DeleteObjects(ctx context.Context, path []string) error

func (*UploaderObs) GetUploaderType

func (u *UploaderObs) GetUploaderType() string

func (*UploaderObs) MultipartUpload

func (u *UploaderObs) MultipartUpload(ctx context.Context, file *multipart.FileHeader, randomly bool, chunkSize int) (path, fileUrl string, err error)

func (*UploaderObs) Upload

func (u *UploaderObs) Upload(ctx context.Context, file *multipart.FileHeader, randomly bool) (path, fileUrl string, err error)

type UploaderObsConfig

type UploaderObsConfig struct {
	AccessKeyID     string
	SecretAccessKey string
	EndPoint        string
	BucketName      string
	Path            string
	Domain          string
}

type UploaderOss

type UploaderOss struct {
	// contains filtered or unexported fields
}

func NewUploaderOss

func NewUploaderOss(config UploaderOssConfig) (uploader *UploaderOss, err error)

func (*UploaderOss) DeleteObjects

func (u *UploaderOss) DeleteObjects(ctx context.Context, path []string) error

func (*UploaderOss) GetUploaderType

func (u *UploaderOss) GetUploaderType() string

func (*UploaderOss) MultipartUpload

func (u *UploaderOss) MultipartUpload(ctx context.Context, file *multipart.FileHeader, randomly bool, chunkSize int) (path, fileUrl string, err error)

func (*UploaderOss) Upload

func (u *UploaderOss) Upload(ctx context.Context, file *multipart.FileHeader, randomly bool) (path, fileUrl string, err error)

type UploaderOssConfig

type UploaderOssConfig struct {
	AccessKeyID     string
	SecretAccessKey string
	EndPoint        string
	BucketName      string
	Path            string
	Domain          string
}

type UploaderQiNiu

type UploaderQiNiu struct {
	// contains filtered or unexported fields
}

func NewUploaderQiNiu

func NewUploaderQiNiu(config UploaderQiNiuConfig) (uploader *UploaderQiNiu, err error)

func (*UploaderQiNiu) DeleteObjects

func (u *UploaderQiNiu) DeleteObjects(ctx context.Context, path []string) error

func (*UploaderQiNiu) GetUploaderType

func (u *UploaderQiNiu) GetUploaderType() string

func (*UploaderQiNiu) MultipartUpload

func (u *UploaderQiNiu) MultipartUpload(ctx context.Context, file *multipart.FileHeader, randomly bool, chunkSize int) (path, fileUrl string, err error)

func (*UploaderQiNiu) Upload

func (u *UploaderQiNiu) Upload(ctx context.Context, file *multipart.FileHeader, randomly bool) (path, fileUrl string, err error)

type UploaderQiNiuConfig

type UploaderQiNiuConfig struct {
	AccessKeyID     string
	SecretAccessKey string
	BucketName      string
	Path            string
	Domain          string
	UseSSL          bool
	UseCdn          bool
}

Directories

Path Synopsis
pkg
log

Jump to

Keyboard shortcuts

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