feat: user improve
CI / changes (push) Successful in 1m31s
CI / ad (push) Successful in 32s
CI / admin (push) Successful in 26s
CI / analysis (push) Successful in 28s
CI / bff (push) Successful in 23s
CI / chore (push) Successful in 24s
CI / equipment (push) Successful in 21s
CI / express (push) Successful in 21s
CI / factory (push) Successful in 18s
CI / message (push) Successful in 18s
CI / order (push) Successful in 21s
CI / payment (push) Successful in 20s
CI / percutaneous (push) Successful in 19s
CI / product (push) Successful in 21s
CI / record (push) Successful in 21s
CI / sale (push) Successful in 20s
CI / store (push) Successful in 25s
CI / support (push) Successful in 21s
CI / task (push) Successful in 20s
CI / user (push) Successful in 22s
CI / water (push) Successful in 20s
CI / wecom (push) Successful in 21s
CI / ws (push) Successful in 8s

This commit is contained in:
zzw
2026-10-27 13:01:24 +08:00
parent 70543fbcb0
commit b77a1f1b95
20 changed files with 1110 additions and 171 deletions
+6 -1
View File
@@ -36,6 +36,7 @@ type UploadInput struct {
Filename string
Content []byte
ContentType string
Dir string // 可选,覆盖配置 oss.dir
}
func LoadConfig() Config {
@@ -84,7 +85,11 @@ func Upload(in UploadInput) (*Result, error) {
return nil, fmt.Errorf("file too large, max %d bytes", MaxUploadBytes)
}
objectKey := buildObjectKey(cfg.Dir, in.Filename)
dir := cfg.Dir
if strings.TrimSpace(in.Dir) != "" {
dir = in.Dir
}
objectKey := buildObjectKey(dir, in.Filename)
endpoint := normalizeEndpoint(cfg.Endpoint, cfg.BucketName)
client, err := alioss.New(endpoint, cfg.AccessKeyId, cfg.AccessKeySecret)