Fix: S3 adaption for minio

pull/630/head
HFO4 4 years ago
parent 41eb84a221
commit 77394313aa

@ -1 +1 @@
Subproject commit 8f2a9c3d8138e5726fa841d239ca3a2bd946dc1b
Subproject commit f342a2a7774c5163f8d5a6760b556b69d6fe498f

@ -3,6 +3,7 @@ package model
import (
"encoding/gob"
"encoding/json"
"fmt"
"net/url"
"path"
"path/filepath"
@ -239,7 +240,7 @@ func (policy *Policy) GetUploadURL() string {
return policy.Server
}
var controller *url.URL
controller, _ := url.Parse("")
switch policy.Type {
case "local", "onedrive":
return "/api/v3/file/upload"
@ -251,9 +252,17 @@ func (policy *Policy) GetUploadURL() string {
return policy.Server
case "upyun":
return "https://v0.api.upyun.com/" + policy.BucketName
default:
controller, _ = url.Parse("")
case "s3":
if policy.Server == "" {
return fmt.Sprintf("https://%s.s3.%s.amazonaws.com/", policy.BucketName,
policy.OptionsSerialized.Region)
}
if !strings.Contains(policy.Server, policy.BucketName) {
controller, _ = url.Parse("/" + policy.BucketName)
}
}
return server.ResolveReference(controller).String()
}

@ -62,6 +62,7 @@ func (handler *Driver) InitS3Client() error {
Region: &handler.Policy.OptionsSerialized.Region,
S3ForcePathStyle: aws.Bool(false),
})
if err != nil {
return err
}

@ -110,6 +110,7 @@ func COSCallback(c *gin.Context) {
// S3Callback S3上传完成客户端回调
func S3Callback(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", "*")
var callbackBody callback.S3Callback
if err := c.ShouldBindQuery(&callbackBody); err == nil {
res := callbackBody.PreProcess(c)

Loading…
Cancel
Save