fix(onedrive,ali): upload progress

pull/1604/head
Noah Hsu 2022-08-31 22:04:04 +08:00
parent 7ac1d14eeb
commit b73dce33aa
2 changed files with 3 additions and 2 deletions

View File

@ -256,7 +256,7 @@ func (d *AliDrive) Put(ctx context.Context, dstDir model.Obj, stream model.FileS
file.ReadCloser = tempFile 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)) req, err := http.NewRequest("PUT", partInfo.UploadUrl, io.LimitReader(file, DEFAULT))
if err != nil { if err != nil {
return err return err
@ -266,6 +266,7 @@ func (d *AliDrive) Put(ctx context.Context, dstDir model.Obj, stream model.FileS
return err return err
} }
res.Body.Close() res.Body.Close()
up(i * 100 / count)
} }
var resp2 base.Json var resp2 base.Json
_, err, e = d.request("https://api.aliyundrive.com/v2/file/complete", http.MethodPost, func(req *resty.Request) { _, err, e = d.request("https://api.aliyundrive.com/v2/file/complete", http.MethodPost, func(req *resty.Request) {

View File

@ -194,7 +194,7 @@ func (d *Onedrive) upBig(ctx context.Context, dstDir model.Obj, stream model.Fil
return errors.New(string(data)) return errors.New(string(data))
} }
res.Body.Close() res.Body.Close()
up(int(finish / stream.GetSize())) up(int(finish * 100 / stream.GetSize()))
} }
return nil return nil
} }