Documentation
¶
Index ¶
- type CloudinaryProvider
- type DeleteInput
- type FileInfo
- type GetSignedURLInput
- type GetURLInput
- type ListInput
- type LocalProvider
- func (p *LocalProvider) Delete(ctx context.Context, input DeleteInput) error
- func (p *LocalProvider) Exists(ctx context.Context, path string) (bool, error)
- func (p *LocalProvider) GetSignedURL(ctx context.Context, input GetSignedURLInput) (string, error)
- func (p *LocalProvider) GetURL(ctx context.Context, input GetURLInput) (string, error)
- func (p *LocalProvider) Name() string
- func (p *LocalProvider) Upload(ctx context.Context, file io.Reader, path string) (string, error)
- type LocalStorageProvider
- func (p *LocalStorageProvider) Delete(ctx context.Context, input DeleteInput) error
- func (p *LocalStorageProvider) GetSignedURL(ctx context.Context, input GetSignedURLInput) (string, error)
- func (p *LocalStorageProvider) GetURL(ctx context.Context, input GetURLInput) (string, error)
- func (p *LocalStorageProvider) List(ctx context.Context, input ListInput) ([]FileInfo, error)
- func (p *LocalStorageProvider) Move(ctx context.Context, input MoveInput) error
- func (p *LocalStorageProvider) Upload(ctx context.Context, input UploadInput) (UploadOutput, error)
- type MoveInput
- type OSSProvider
- func (p *OSSProvider) Delete(ctx context.Context, path string) error
- func (p *OSSProvider) Exists(ctx context.Context, path string) (bool, error)
- func (p *OSSProvider) GetSignedURL(ctx context.Context, path string, expiry time.Duration) (string, error)
- func (p *OSSProvider) Name() string
- func (p *OSSProvider) Upload(ctx context.Context, file io.Reader, path string) (string, error)
- type ProviderConfig
- type ProviderFactory
- type S3Provider
- type StorageProvider
- type UploadInput
- type UploadOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudinaryProvider ¶
type CloudinaryProvider struct {
}
CloudinaryProvider Cloudinary 存储提供者(接口定义)
type FileInfo ¶
type FileInfo struct {
Name string
Size int64
IsDir bool
UpdatedAt int64
Metadata map[string]interface{}
}
FileInfo 文件信息
type GetSignedURLInput ¶
GetSignedURLInput 获取签名 URL 输入
type LocalProvider ¶
type LocalProvider struct {
// contains filtered or unexported fields
}
LocalProvider implements storage.Provider for local filesystem
func NewLocalProvider ¶
func NewLocalProvider(basePath, baseURL string) (*LocalProvider, error)
NewLocalProvider creates a new local storage provider
func (*LocalProvider) Delete ¶
func (p *LocalProvider) Delete(ctx context.Context, input DeleteInput) error
Delete removes a file from the local filesystem
func (*LocalProvider) GetSignedURL ¶
func (p *LocalProvider) GetSignedURL(ctx context.Context, input GetSignedURLInput) (string, error)
GetSignedURL for local provider just returns the public URL
func (*LocalProvider) GetURL ¶
func (p *LocalProvider) GetURL(ctx context.Context, input GetURLInput) (string, error)
GetURL returns the public URL for a file
func (*LocalProvider) Name ¶
func (p *LocalProvider) Name() string
type LocalStorageProvider ¶
type LocalStorageProvider struct {
// contains filtered or unexported fields
}
LocalStorageProvider 本地存储提供者(使用新接口)
func NewLocalStorageProvider ¶
func NewLocalStorageProvider(basePath, baseURL string) (*LocalStorageProvider, error)
NewLocalStorageProvider 创建本地存储提供者
func (*LocalStorageProvider) Delete ¶
func (p *LocalStorageProvider) Delete(ctx context.Context, input DeleteInput) error
Delete 删除文件
func (*LocalStorageProvider) GetSignedURL ¶
func (p *LocalStorageProvider) GetSignedURL(ctx context.Context, input GetSignedURLInput) (string, error)
GetSignedURL 获取签名 URL(本地存储不需要签名)
func (*LocalStorageProvider) GetURL ¶
func (p *LocalStorageProvider) GetURL(ctx context.Context, input GetURLInput) (string, error)
GetURL 获取文件 URL
func (*LocalStorageProvider) Move ¶
func (p *LocalStorageProvider) Move(ctx context.Context, input MoveInput) error
Move 移动文件
func (*LocalStorageProvider) Upload ¶
func (p *LocalStorageProvider) Upload(ctx context.Context, input UploadInput) (UploadOutput, error)
Upload 上传文件
type OSSProvider ¶
type OSSProvider struct {
// contains filtered or unexported fields
}
OSSProvider implements storage.Provider for Aliyun OSS
func NewOSSProvider ¶
func NewOSSProvider(endpoint, accessKeyID, accessKeySecret, bucketName, domain string) (*OSSProvider, error)
NewOSSProvider creates a new OSS storage provider Endpoint: oss-cn-hangzhou.aliyuncs.com
func (*OSSProvider) Delete ¶
func (p *OSSProvider) Delete(ctx context.Context, path string) error
Delete removes a file from OSS
func (*OSSProvider) GetSignedURL ¶
func (p *OSSProvider) GetSignedURL(ctx context.Context, path string, expiry time.Duration) (string, error)
GetSignedURL generates a signed URL for private object access
func (*OSSProvider) Name ¶
func (p *OSSProvider) Name() string
type ProviderConfig ¶
type ProviderConfig struct {
Type string `json:"type"` // local, s3, cloudinary
Settings map[string]interface{} `json:"settings"` // 各提供者特定配置
}
ProviderConfig 提供者配置
type ProviderFactory ¶
type ProviderFactory struct {
// contains filtered or unexported fields
}
ProviderFactory 提供者工厂
func (*ProviderFactory) CreateFromConfig ¶
func (f *ProviderFactory) CreateFromConfig(config ProviderConfig) (StorageProvider, error)
CreateFromConfig 从配置创建提供者
func (*ProviderFactory) Get ¶
func (f *ProviderFactory) Get(name string) (StorageProvider, error)
Get 获取提供者
func (*ProviderFactory) Register ¶
func (f *ProviderFactory) Register(name string, provider StorageProvider)
Register 注册提供者
type StorageProvider ¶
type StorageProvider interface {
Upload(ctx context.Context, input UploadInput) (UploadOutput, error)
Delete(ctx context.Context, input DeleteInput) error
GetURL(ctx context.Context, input GetURLInput) (string, error)
GetSignedURL(ctx context.Context, input GetSignedURLInput) (string, error)
Move(ctx context.Context, input MoveInput) error
List(ctx context.Context, input ListInput) ([]FileInfo, error)
}
StorageProvider 存储提供者接口