xyxie 1 год назад
Родитель
Сommit
2df0287e1c
2 измененных файлов с 5 добавлено и 1 удалено
  1. 3 1
      services/aws_s3.go
  2. 2 0
      utils/config.go

+ 3 - 1
services/aws_s3.go

@@ -124,11 +124,13 @@ func (m *S3Oss) UploadFile(fileName, localFile, savePath string) (resourceUrl st
 		path = uploadDir + time.Now().Format("200601/20060102/") + fileName
 	}
 	putObjectInput := &s3.PutObjectInput{
-		ACL:    aws.String(s3.ObjectCannedACLPublicRead),
 		Bucket: aws.String(bucketName),
 		Key:    aws.String(path),
 		Body:   bytes.NewReader(fileContent),
 	}
+	if utils.S3OpenAcl == "1" {
+		putObjectInput.ACL = aws.String(s3.ObjectCannedACLPublicRead)
+	}
 	fmt.Printf("put object input: %+v\n", putObjectInput)
 	_, e = client.PutObject(putObjectInput)
 	if e != nil {

+ 2 - 0
utils/config.go

@@ -227,6 +227,7 @@ var (
 	S3EndpointPort    string
 	S3Protocol        string
 	S3DisableSSL      string
+	S3OpenAcl         string
 )
 
 func init() {
@@ -501,6 +502,7 @@ func init() {
 		S3EndpointPort = config["s3_endpoint_port"]
 		S3Protocol = config["s3_protocol"]
 		S3DisableSSL = config["s3_disable_ssl"]
+		S3OpenAcl = config["s3_open_acl"]
 	}
 
 	// 生成长图服务地址