Skip to content

Commit

Permalink
fix(onedrive,ali): upload progress
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 31, 2022
1 parent 7ac1d14 commit b73dce3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion drivers/aliyundrive/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (d *AliDrive) Put(ctx context.Context, dstDir model.Obj, stream model.FileS
file.ReadCloser = tempFile
}

for _, partInfo := range resp.PartInfoList {
for i, partInfo := range resp.PartInfoList {
req, err := http.NewRequest("PUT", partInfo.UploadUrl, io.LimitReader(file, DEFAULT))
if err != nil {
return err
Expand All @@ -266,6 +266,7 @@ func (d *AliDrive) Put(ctx context.Context, dstDir model.Obj, stream model.FileS
return err
}
res.Body.Close()
up(i * 100 / count)
}
var resp2 base.Json
_, err, e = d.request("https://api.aliyundrive.com/v2/file/complete", http.MethodPost, func(req *resty.Request) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/onedrive/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (d *Onedrive) upBig(ctx context.Context, dstDir model.Obj, stream model.Fil
return errors.New(string(data))
}
res.Body.Close()
up(int(finish / stream.GetSize()))
up(int(finish * 100 / stream.GetSize()))
}
return nil
}

0 comments on commit b73dce3

Please sign in to comment.