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 ( import (
"encoding/gob" "encoding/gob"
"encoding/json" "encoding/json"
"fmt"
"net/url" "net/url"
"path" "path"
"path/filepath" "path/filepath"
@ -239,7 +240,7 @@ func (policy *Policy) GetUploadURL() string {
return policy.Server return policy.Server
} }
var controller *url.URL controller, _ := url.Parse("")
switch policy.Type { switch policy.Type {
case "local", "onedrive": case "local", "onedrive":
return "/api/v3/file/upload" return "/api/v3/file/upload"
@ -251,9 +252,17 @@ func (policy *Policy) GetUploadURL() string {
return policy.Server return policy.Server
case "upyun": case "upyun":
return "https://v0.api.upyun.com/" + policy.BucketName return "https://v0.api.upyun.com/" + policy.BucketName
default: case "s3":
controller, _ = url.Parse("") 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() return server.ResolveReference(controller).String()
} }

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

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

Loading…
Cancel
Save