xyxie 1 年之前
父节点
当前提交
5c9b3d52a1
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      services/aws_s3.go

+ 3 - 1
services/aws_s3.go

@@ -11,6 +11,7 @@ import (
 	"github.com/aws/aws-sdk-go/service/s3"
 	"io/ioutil"
 	"net/http"
+	"os"
 	"time"
 )
 
@@ -60,12 +61,13 @@ func (m *S3Oss) UploadFile(fileName, localFile, savePath string) (resourceUrl st
 		if err != nil {
 			fmt.Println(err.Error())
 		}
+		_ = os.Remove(localFile)
 	}()
 
 	// 默认使用后端这个, 这里有两个配置的原因是
 	// 前端上传跨域问题可能会使用反向代理来解决, 这样的话同一个endpoint就会导致一端正常另一端不正常
 	endpoint := utils.S3Endpoint
-	
+
 	accessKey := utils.S3AccessKeyId
 	secretKey := utils.S3AccessKeySecret
 	region := utils.S3Region