Documentation
¶
Index ¶
- Variables
- func Delete(path string) error
- func Exists(path string) bool
- func Get(path string) ([]byte, error)
- func GetURL(path string) string
- func Init(cfg *config.StorageConfig) error
- func SetStorage(s Storage)
- func Upload(file *multipart.FileHeader, subdir string) (string, error)
- func UploadFromBytes(data []byte, filename, subdir string) (string, error)
- type LocalStorage
- func (s *LocalStorage) Delete(path string) error
- func (s *LocalStorage) Exists(path string) bool
- func (s *LocalStorage) Get(path string) ([]byte, error)
- func (s *LocalStorage) GetURL(path string) string
- func (s *LocalStorage) Upload(file *multipart.FileHeader, subdir string) (string, error)
- func (s *LocalStorage) UploadFromBytes(data []byte, filename, subdir string) (string, error)
- type OSSStorage
- func (s *OSSStorage) Delete(path string) error
- func (s *OSSStorage) Exists(path string) bool
- func (s *OSSStorage) Get(path string) ([]byte, error)
- func (s *OSSStorage) GetSignedURL(path string, expire time.Duration) (string, error)
- func (s *OSSStorage) GetURL(path string) string
- func (s *OSSStorage) Upload(file *multipart.FileHeader, subdir string) (string, error)
- func (s *OSSStorage) UploadFromBytes(data []byte, filename, subdir string) (string, error)
- type Storage
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrStorageNotInitialized = errors.New("storage not initialized")
Functions ¶
Types ¶
type LocalStorage ¶
type LocalStorage struct {
// contains filtered or unexported fields
}
LocalStorage 本地存储
func NewLocalStorage ¶
func NewLocalStorage(cfg *config.LocalStorageConfig) *LocalStorage
NewLocalStorage 创建本地存储实例
func (*LocalStorage) Upload ¶
func (s *LocalStorage) Upload(file *multipart.FileHeader, subdir string) (string, error)
Upload 上传文件
func (*LocalStorage) UploadFromBytes ¶
func (s *LocalStorage) UploadFromBytes(data []byte, filename, subdir string) (string, error)
UploadFromBytes 从字节数组上传文件
type OSSStorage ¶
type OSSStorage struct {
// contains filtered or unexported fields
}
OSSStorage OSS 存储
func NewOSSStorage ¶
func NewOSSStorage(cfg *config.OSSStorageConfig) (*OSSStorage, error)
NewOSSStorage 创建 OSS 存储实例
func (*OSSStorage) GetSignedURL ¶
GetSignedURL 获取带签名的临时访问 URL(用于私有文件)
func (*OSSStorage) Upload ¶
func (s *OSSStorage) Upload(file *multipart.FileHeader, subdir string) (string, error)
Upload 上传文件到 OSS
func (*OSSStorage) UploadFromBytes ¶
func (s *OSSStorage) UploadFromBytes(data []byte, filename, subdir string) (string, error)
UploadFromBytes 从字节数组上传文件到 OSS
type Storage ¶
type Storage interface {
Upload(file *multipart.FileHeader, subdir string) (string, error)
UploadFromBytes(data []byte, filename, subdir string) (string, error)
GetURL(path string) string
Delete(path string) error
Get(path string) ([]byte, error)
Exists(path string) bool
}
Storage 存储接口
Click to show internal directories.
Click to hide internal directories.