hsun пре 1 година
родитељ
комит
7eaa558138
3 измењених фајлова са 10 додато и 0 уклоњено
  1. 2 0
      services/aws_s3.go
  2. 4 0
      services/minio.go
  3. 4 0
      services/oss.go

+ 2 - 0
services/aws_s3.go

@@ -9,6 +9,7 @@ import (
 	"github.com/aws/aws-sdk-go/aws/session"
 	"github.com/aws/aws-sdk-go/service/s3"
 	"io/ioutil"
+	"os"
 	"time"
 )
 
@@ -58,6 +59,7 @@ func (m *S3Oss) UploadFile(fileName, localFile, savePath string) (resourceUrl st
 		if err != nil {
 			fmt.Println(err.Error())
 		}
+		_ = os.Remove(localFile)
 	}()
 
 	endpoint := utils.S3Endpoint

+ 4 - 0
services/minio.go

@@ -7,6 +7,7 @@ import (
 	"github.com/minio/minio-go/v7"
 	"github.com/minio/minio-go/v7/pkg/credentials"
 	"log"
+	"os"
 	"time"
 )
 
@@ -403,6 +404,9 @@ type MinioOss struct{}
 
 // UploadFile 上传文件
 func (m *MinioOss) UploadFile(fileName, filePath, savePath string) (string, error) {
+	defer func() {
+		_ = os.Remove(filePath)
+	}()
 	if utils.MinIoAccessKeyId == `` || utils.MinIoAccessKeySecret == `` {
 		return "0", errors.New("MinIo信息未配置")
 	}

+ 4 - 0
services/oss.go

@@ -6,6 +6,7 @@ import (
 	"eta/eta_api/services/alarm_msg"
 	"fmt"
 	"github.com/aliyun/aliyun-oss-go-sdk/oss"
+	"os"
 	"time"
 
 	"eta/eta_api/utils"
@@ -255,6 +256,9 @@ type AliOss struct{}
 
 // UploadFile 上传文件
 func (m *AliOss) UploadFile(fileName, filePath, savePath string) (string, error) {
+	defer func() {
+		_ = os.Remove(filePath)
+	}()
 	if utils.AccessKeyId == `` {
 		return "0", errors.New("阿里云信息未配置")
 	}