|
|
@ -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) |
|
|
|