storage

package
v1.10.5 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MulanPSL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init added in v1.9.13

func Init()

Types

type BackendConfig added in v1.9.18

type BackendConfig struct {
	Code    string      `yaml:"code"`
	Backend BackendType `yaml:"backend"` // local, s3
	BaseUrl string      `yaml:"baseUrl"`
}

type BackendType added in v1.9.20

type BackendType string
const (
	BackendTypeLocal     BackendType = "local"
	BackendTypeS3        BackendType = "s3"
	BackendTypeQcloudCOS BackendType = "qcloud-cos"
)

func GetBackendType added in v1.9.15

func GetBackendType(inMap map[string]interface{}) BackendType

type FileInfo

type FileInfo struct {
	database.Model
	ContentType    string
	OriginFilename string
	StoredFilename string
	FileUrl        string
	Size           int
}

type ILocalTempBackend added in v1.9.17

type ILocalTempBackend interface {
	ReadTempFile(objectName string) (content []byte, err error) // ReadTempFile reads the content of a temporary file from the local storage backend
	SaveTempFile(objectName string, content []byte) (string, error)
	LocalTempPath(objectName string) string
	DeleteTempFile(objectName string) error
}

type IStorageBackend added in v1.9.18

type IStorageBackend interface {
	ReadFile(objectName string) (content []byte, err error)
	Save(objectName string, content []byte) error
	Delete(objectName string) error
	GetUrl(objectName string) string
	Ping() error
}

func GetStorageServiceByCode added in v1.9.15

func GetStorageServiceByCode(code string) (service IStorageBackend)

type LocalConfig added in v1.9.15

type LocalConfig struct {
	BackendConfig
	Path string `yaml:"path"`
}

func LocalConfigFromMap added in v1.9.15

func LocalConfigFromMap(config map[string]interface{}) (cfg *LocalConfig)

type QcloudCOSConfig added in v1.9.20

type QcloudCOSConfig struct {
	BackendConfig
	LocalProxy bool   `yaml:"localProxy"`
	Bucket     string `yaml:"bucket"`
	Region     string `yaml:"region"`
	AccessKey  string `yaml:"accessKey"`
	SecretKey  string `yaml:"secretKey"`
}

func QcloudCosConfigFromMap added in v1.9.20

func QcloudCosConfigFromMap(config map[string]interface{}) (cfg *QcloudCOSConfig)

type S3Config added in v1.9.15

type S3Config struct {
	BackendConfig
	LocalProxy bool   `yaml:"localProxy"`
	Bucket     string `yaml:"bucket"`
	Region     string `yaml:"region"`
	AccessKey  string `yaml:"accessKey"`
	SecretKey  string `yaml:"secretKey"`
	Endpoint   string `yaml:"endpoint"`
}

func S3ConfigFromMap added in v1.9.15

func S3ConfigFromMap(config map[string]interface{}) (cfg *S3Config)

type StorageService

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

func GetDefaultStorageService added in v1.9.15

func GetDefaultStorageService() (service *StorageService)

func GetLocalStorageService added in v1.9.15

func GetLocalStorageService() (service *StorageService)

func GetStorageService added in v1.9.10

func GetStorageService() (service *StorageService)

func GetStorageServiceInSession added in v1.9.23

func GetStorageServiceInSession(session *gorm.DB) *StorageService

func (*StorageService) DeleteFile

func (svc *StorageService) DeleteFile(fileInfoId string) (err error)

func (*StorageService) GetFileInfo

func (svc *StorageService) GetFileInfo(fileInfoId string, withContent bool) (fileInfo *FileInfo, content []byte, err error)

func (*StorageService) GetUrl added in v1.9.12

func (svc *StorageService) GetUrl(filename string) string

func (*StorageService) Save

func (svc *StorageService) Save(originFilename string, content []byte) (fileInfo *FileInfo, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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