Skip to content

Commit

Permalink
Fix: S3 adaption for minio
Browse files Browse the repository at this point in the history
  • Loading branch information
HFO4 committed Oct 11, 2020
1 parent 41eb84a commit 7739431
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion assets
15 changes: 12 additions & 3 deletions models/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package model
import (
"encoding/gob"
"encoding/json"
"fmt"
"net/url"
"path"
"path/filepath"
Expand Down Expand Up @@ -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"
Expand All @@ -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()
}

Expand Down
1 change: 1 addition & 0 deletions pkg/filesystem/driver/s3/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (handler *Driver) InitS3Client() error {
Region: &handler.Policy.OptionsSerialized.Region,
S3ForcePathStyle: aws.Bool(false),
})

if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions routers/controllers/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7739431

Please sign in to comment.