[修复阿里云OSS图片上传路径不一致错误]
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||
"go.uber.org/zap"
|
||||
"mime/multipart"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -27,7 +26,8 @@ func (*AliyunOSS) UploadFile(file *multipart.FileHeader) (string, string, error)
|
||||
}
|
||||
defer f.Close() // 创建文件 defer 关闭
|
||||
// 上传阿里云路径 文件名格式 自己可以改 建议保证唯一性
|
||||
yunFileTmpPath := filepath.Join("uploads", time.Now().Format("2006-01-02")) + "/" + file.Filename
|
||||
//yunFileTmpPath := filepath.Join("uploads", time.Now().Format("2006-01-02")) + "/" + file.Filename
|
||||
yunFileTmpPath := global.GVA_CONFIG.AliyunOSS.BasePath + "/" + "uploads" + "/" + time.Now().Format("2006-01-02") + "/" + file.Filename
|
||||
|
||||
// 上传文件流。
|
||||
err = bucket.PutObject(yunFileTmpPath, f)
|
||||
|
Reference in New Issue
Block a user