43 lines
1.6 KiB
Go
43 lines
1.6 KiB
Go
// s3_stub.go 是 internal/storage/s3.go 的本地编译桩:s3.go 依赖 cgo 库
|
|
// chai2010/webp(需要 libwebp + C 工具链),Windows 沙箱无此环境。
|
|
// 通过 `go build -overlay=dev/overlay.json` 用本文件替换 s3.go,做全模块类型检查。
|
|
// 符号覆盖 = s3.go 中被包内其他文件(oss.go 引用 isSupportedImage)与
|
|
// 包外调用方(route/user、route/question、route/chat 等)引用的全部标识符。
|
|
// 桩仅在类型检查时生效,不会被真正调用;生产构建在 Linux(cgo + libwebp)下不受影响。
|
|
package storage
|
|
|
|
import (
|
|
"io"
|
|
"mime/multipart"
|
|
)
|
|
|
|
// MaxUploadBytes 与真实实现保持一致(8MB 单图上限,bodylimit 中间件依赖此值语义)。
|
|
const MaxUploadBytes = 8 * 1024 * 1024
|
|
|
|
// EncodeSpec 与真实实现的编码档位结构保持字段一致。
|
|
type EncodeSpec struct {
|
|
MaxSide int
|
|
Quality float32
|
|
}
|
|
|
|
// GeneralEncodeSpec 与真实实现保持一致(route/question 引用)。
|
|
var GeneralEncodeSpec = EncodeSpec{MaxSide: 1600, Quality: 80}
|
|
|
|
func UploadPictureToS3(file multipart.File, fileHeader *multipart.FileHeader) (string, error) {
|
|
return "", nil
|
|
}
|
|
|
|
func UploadAvatarToS3(file multipart.File, fileHeader *multipart.FileHeader) (string, error) {
|
|
return "", nil
|
|
}
|
|
|
|
func UploadBackgroundToS3(file multipart.File, fileHeader *multipart.FileHeader) (string, error) {
|
|
return "", nil
|
|
}
|
|
|
|
func ConvertStaticImageToWebP(r io.Reader, spec EncodeSpec) ([]byte, error) { return nil, nil }
|
|
|
|
func ConvertGifToAnimatedWebP(gifData []byte) ([]byte, error) { return nil, nil }
|
|
|
|
func isSupportedImage(data []byte) bool { return true }
|