Skip to content

Commit e0e0e78

Browse files
RebellioncryRebellioncry
andauthored
AwsS3新增配置属性,可以兼容minio (flipped-aurora#932)
Co-authored-by: Rebellioncry <23714@aomai.com>
1 parent 1d0d00e commit e0e0e78

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

server/config.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,13 @@ tencent-cos:
150150
base-url: 'https://gin.vue.admin'
151151
path-prefix: 'github.com/flipped-aurora/gin-vue-admin/server'
152152

153-
# aws s3 configuration
153+
# aws s3 configuration (minio compatible)
154154
aws-s3:
155155
bucket: xxxxx-10005608
156156
region: ap-shanghai
157+
endpoint: ''
158+
s3-force-path-style: false
159+
disable-ssl: false
157160
secret-id: xxxxxxxx
158161
secret-key: xxxxxxxx
159162
base-url: https://gin.vue.admin

server/config/oss_aws.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package config
22

33
type AwsS3 struct {
4-
Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"`
5-
Region string `mapstructure:"region" json:"region" yaml:"region"`
6-
SecretID string `mapstructure:"secret-id" json:"secretID" yaml:"secret-id"`
7-
SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"`
8-
BaseURL string `mapstructure:"base-url" json:"baseURL" yaml:"base-url"`
9-
PathPrefix string `mapstructure:"path-prefix" json:"pathPrefix" yaml:"path-prefix"`
4+
Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"`
5+
Region string `mapstructure:"region" json:"region" yaml:"region"`
6+
Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint"`
7+
S3ForcePathStyle bool `mapstructure:"s3-force-path-style" json:"s3ForcePathStyle" yaml:"s3-force-path-style"`
8+
DisableSSL bool `mapstructure:"disable-ssl" json:"disableSSL" yaml:"disable-ssl"`
9+
SecretID string `mapstructure:"secret-id" json:"secretID" yaml:"secret-id"`
10+
SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"`
11+
BaseURL string `mapstructure:"base-url" json:"baseURL" yaml:"base-url"`
12+
PathPrefix string `mapstructure:"path-prefix" json:"pathPrefix" yaml:"path-prefix"`
1013
}

server/utils/upload/aws_s3.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ func (*AwsS3) DeleteFile(key string) error {
8383
// newSession Create S3 session
8484
func newSession() *session.Session {
8585
sess, _ := session.NewSession(&aws.Config{
86-
Region: aws.String(global.GVA_CONFIG.AwsS3.Region),
86+
Region: aws.String(global.GVA_CONFIG.AwsS3.Region),
87+
Endpoint: aws.String(global.GVA_CONFIG.AwsS3.Endpoint), //minio在这里设置地址,可以兼容
88+
S3ForcePathStyle: aws.Bool(global.GVA_CONFIG.AwsS3.S3ForcePathStyle),
89+
DisableSSL: aws.Bool(global.GVA_CONFIG.AwsS3.DisableSSL),
8790
Credentials: credentials.NewStaticCredentials(
8891
global.GVA_CONFIG.AwsS3.SecretID,
8992
global.GVA_CONFIG.AwsS3.SecretKey,

0 commit comments

Comments
 (0)