初始化
This commit is contained in:
37
server/storage/engine.go
Normal file
37
server/storage/engine.go
Normal file
@@ -0,0 +1,37 @@
|
||||
// Package storage 提供文件存储引擎抽象层
|
||||
// 通过接口解耦文件存储, 支持本地磁盘、MinIO、S3等多种后端
|
||||
package storage
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// Engine 存储引擎接口
|
||||
// 所有存储后端(local/minio/s3/oss)都必须实现此接口
|
||||
type Engine interface {
|
||||
// Upload 上传文件
|
||||
// storageKey: 存储路径标识, reader: 文件内容流, size: 文件大小
|
||||
// 返回实际的storageKey和错误
|
||||
Upload(storageKey string, reader io.Reader, size int64) error
|
||||
|
||||
// Download 下载文件
|
||||
// 返回文件内容流, 调用方负责关闭
|
||||
Download(storageKey string) (io.ReadCloser, error)
|
||||
|
||||
// Delete 删除文件
|
||||
Delete(storageKey string) error
|
||||
|
||||
// Exists 判断文件是否存在
|
||||
Exists(storageKey string) (bool, error)
|
||||
|
||||
// GetURL 获取文件访问URL
|
||||
// 本地存储返回相对路径, 对象存储返回完整URL
|
||||
GetURL(storageKey string) string
|
||||
}
|
||||
|
||||
// StorageResult 上传结果
|
||||
type StorageResult struct {
|
||||
StorageKey string // 存储标识
|
||||
Size int64 // 文件大小
|
||||
MD5 string // 文件MD5
|
||||
}
|
||||
Reference in New Issue
Block a user