diff --git a/drivers/aliyundrive_open/driver.go b/drivers/aliyundrive_open/driver.go index dd2c0107..0f454ad4 100644 --- a/drivers/aliyundrive_open/driver.go +++ b/drivers/aliyundrive_open/driver.go @@ -5,6 +5,7 @@ import ( "io" "math" "net/http" + "strings" "github.com/alist-org/alist/v3/drivers/base" "github.com/alist-org/alist/v3/internal/driver" @@ -170,7 +171,12 @@ func (d *AliyundriveOpen) Put(ctx context.Context, dstDir model.Obj, stream mode if utils.IsCanceled(ctx) { return ctx.Err() } - req, err := http.NewRequest("PUT", partInfo.UploadUrl, io.LimitReader(stream, DEFAULT)) + uploadUrl := partInfo.UploadUrl + if d.InternalUpload { + //Replace a known public Host with an internal Host + uploadUrl = strings.ReplaceAll(uploadUrl, "https://cn-beijing-data.aliyundrive.net/", "http://ccp-bj29-bj-1592982087.oss-cn-beijing-internal.aliyuncs.com/") + } + req, err := http.NewRequest("PUT", uploadUrl, io.LimitReader(stream, DEFAULT)) if err != nil { return err } diff --git a/drivers/aliyundrive_open/meta.go b/drivers/aliyundrive_open/meta.go index a6ef1dcc..ca6ad62c 100644 --- a/drivers/aliyundrive_open/meta.go +++ b/drivers/aliyundrive_open/meta.go @@ -14,6 +14,7 @@ type Addition struct { ClientID string `json:"client_id" required:"false" help:"Keep it empty if you don't have one"` ClientSecret string `json:"client_secret" required:"false" help:"Keep it empty if you don't have one"` RemoveWay string `json:"remove_way" required:"true" type:"select" options:"trash,delete"` + InternalUpload bool `json:"internal_upload" help:"If you are using Aliyun ECS in Beijing, you can turn it on to boost the upload speed"` } var config = driver.Config{