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

@@ -38,6 +38,7 @@ func (*Qiniu) UploadFile(file *multipart.FileHeader) (string, string, 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) // 文件名格式 自己可以改 建议保证唯一性
putErr := formUploader.Put(context.Background(), &ret, upToken, fileKey, f, file.Size, &putExtra)
if putErr != nil {