Documentation
¶
Index ¶
- func Init()
- type BackendConfig
- type BackendType
- type FileInfo
- type ILocalTempBackend
- type IStorageBackend
- type LocalConfig
- type QcloudCOSConfig
- type S3Config
- type StorageService
- func (svc *StorageService) DeleteFile(fileInfoId string) (err error)
- func (svc *StorageService) GetFileInfo(fileInfoId string, withContent bool) (fileInfo *FileInfo, content []byte, err error)
- func (svc *StorageService) GetUrl(filename string) string
- func (svc *StorageService) Save(originFilename string, content []byte) (fileInfo *FileInfo, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 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
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 (*StorageService) GetUrl ¶ added in v1.9.12
func (svc *StorageService) GetUrl(filename string) string
Click to show internal directories.
Click to hide internal directories.