Skip to content

Commit

Permalink
fix: s3 region when use aws (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessy2 authored Aug 7, 2022
1 parent 76ff132 commit 61a0daf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion entity/s3_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"log"
"os"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
Expand Down Expand Up @@ -49,8 +50,15 @@ func (s3Config S3Config) getSession() (*session.Session, error) {
log.Println(err)
}

region := "cn-north-1"
if strings.HasSuffix(s3Config.Endpoint, "amazonaws.com") {
sp := strings.Split(s3Config.Endpoint, ".")
if len(sp) > 1 {
region = sp[1]
}
}
config := &aws.Config{
Region: aws.String("cn-north-1"),
Region: aws.String(region),
Endpoint: aws.String(s3Config.Endpoint),
DisableSSL: aws.Bool(false),
Credentials: creds,
Expand Down

0 comments on commit 61a0daf

Please sign in to comment.