aliyun_oss,qiniu,tencent_cos: fix file open close

This commit is contained in:
黄笑
2021-06-17 14:51:35 +08:00
parent 9364f2a24a
commit 04d7aa9ab4
3 changed files with 3 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ func (*TencentCOS) UploadFile(file *multipart.FileHeader) (string, string, error
global.GVA_LOG.Error("function file.Open() Filed", zap.Any("err", openError.Error()))
return "", "", errors.New("function file.Open() Filed, err:" + openError.Error())
}
defer f.Close() // 创建文件 defer 关闭
fileKey := fmt.Sprintf("%d%s", time.Now().Unix(), file.Filename)
_, err := client.Object.Put(context.Background(), global.GVA_CONFIG.TencentCOS.PathPrefix+"/"+fileKey, f, nil)