@@ -62,7 +62,12 @@ func (m *S3Oss) UploadFile(fileName, localFile, savePath string) (resourceUrl st
}
}()
- endpoint := utils.S3Endpoint
+ // 默认使用后端这个, 这里有两个配置的原因是
+ // 前端上传跨域问题可能会使用反向代理来解决, 这样的话同一个endpoint就会导致一端正常另一端不正常
+ endpoint := utils.S3BackEndpoint
+ if endpoint == "" {
+ endpoint = utils.S3Endpoint
+ }
accessKey := utils.S3AccessKeyId
secretKey := utils.S3AccessKeySecret
region := utils.S3Region
@@ -216,6 +216,7 @@ var (
// S3配置
var (
S3Endpoint string
+ S3BackEndpoint string
S3BucketName string
S3UploadDir string
S3AccessKeyId string
@@ -489,6 +490,7 @@ func init() {
// S3-OSS相关
{
S3Endpoint = config["s3_endpoint"]
+ S3BackEndpoint = config["s3_back_endpoint"]
S3BucketName = config["s3_bucket_name"]
S3Host = config["s3_host"]
S3AccessKeyId = config["s3_access_key_id"]