|
@@ -2,6 +2,7 @@ package services
|
|
|
|
|
|
import (
|
|
|
"bytes"
|
|
|
+ "crypto/tls"
|
|
|
"eta/eta_api/utils"
|
|
|
"fmt"
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
@@ -9,6 +10,7 @@ import (
|
|
|
"github.com/aws/aws-sdk-go/aws/session"
|
|
|
"github.com/aws/aws-sdk-go/service/s3"
|
|
|
"io/ioutil"
|
|
|
+ "net/http"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -72,14 +74,31 @@ func (m *S3Oss) UploadFile(fileName, localFile, savePath string) (resourceUrl st
|
|
|
if forceStyle == "false" {
|
|
|
hostStyle = false
|
|
|
}
|
|
|
+ disableSSL := true // 默认true, 跳过SSL
|
|
|
+ if utils.S3DisableSSL == "false" {
|
|
|
+ disableSSL = false
|
|
|
+ }
|
|
|
+ //fmt.Println("disableSSL: ", disableSSL)
|
|
|
|
|
|
- // 创建AWS会话
|
|
|
- sess, e := session.NewSession(&aws.Config{
|
|
|
+ config := &aws.Config{
|
|
|
Region: aws.String(region),
|
|
|
Credentials: credentials.NewStaticCredentials(accessKey, secretKey, ""),
|
|
|
Endpoint: aws.String(endpoint),
|
|
|
S3ForcePathStyle: aws.Bool(hostStyle),
|
|
|
- })
|
|
|
+ DisableSSL: aws.Bool(disableSSL),
|
|
|
+ }
|
|
|
+ if disableSSL {
|
|
|
+ config.HTTPClient = &http.Client{
|
|
|
+ Transport: &http.Transport{
|
|
|
+ TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //b, _ := json.Marshal(config)
|
|
|
+ //fmt.Println(string(b))
|
|
|
+
|
|
|
+ // 创建AWS会话
|
|
|
+ sess, e := session.NewSession(config)
|
|
|
if e != nil {
|
|
|
err = fmt.Errorf("new session err: %s", e.Error())
|
|
|
return
|