Skip to content

Commit

Permalink
feat(aliyundrive): internal upload (aliyun ECS for Beijing area only) (
Browse files Browse the repository at this point in the history
…#3188)

Co-authored-by: wangwuxuan2011 <[email protected]>
  • Loading branch information
wangwuxuan2011 and wangwuxuan2011 authored Jan 30, 2023
1 parent c92e11d commit e1cd716
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion drivers/aliyundrive/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ func (d *AliDrive) Put(ctx context.Context, dstDir model.Obj, stream model.FileS
if utils.IsCanceled(ctx) {
return ctx.Err()
}
req, err := http.NewRequest("PUT", partInfo.UploadUrl, io.LimitReader(file, DEFAULT))
url := partInfo.UploadUrl
if d.InternalUpload {
url = partInfo.InternalUploadUrl
}
req, err := http.NewRequest("PUT", url, io.LimitReader(file, DEFAULT))
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions drivers/aliyundrive/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Addition struct {
OrderBy string `json:"order_by" type:"select" options:"name,size,updated_at,created_at"`
OrderDirection string `json:"order_direction" type:"select" options:"ASC,DESC"`
RapidUpload bool `json:"rapid_upload"`
InternalUpload bool `json:"internal_upload"`
}

var config = driver.Config{
Expand Down
3 changes: 2 additions & 1 deletion drivers/aliyundrive/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ type UploadResp struct {
FileId string `json:"file_id"`
UploadId string `json:"upload_id"`
PartInfoList []struct {
UploadUrl string `json:"upload_url"`
UploadUrl string `json:"upload_url"`
InternalUploadUrl string `json:"internal_upload_url"`
} `json:"part_info_list"`

RapidUpload bool `json:"rapid_upload"`
Expand Down

0 comments on commit e1cd716

Please sign in to comment.