From 09564102e7ea4336ea6222e0381080a3a8273b21 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Sat, 17 Sep 2022 19:39:19 +0800 Subject: [PATCH] fix(aliyundrive): rapid upload empty file (close #1699) --- drivers/aliyundrive/driver.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/aliyundrive/driver.go b/drivers/aliyundrive/driver.go index 6fa9835c..687b9dd4 100644 --- a/drivers/aliyundrive/driver.go +++ b/drivers/aliyundrive/driver.go @@ -234,7 +234,10 @@ func (d *AliDrive) Put(ctx context.Context, dstDir model.Obj, stream model.FileS buf := make([]byte, 8) r, _ := new(big.Int).SetString(utils.GetMD5Encode(d.AccessToken)[:16], 16) i := new(big.Int).SetInt64(file.GetSize()) - o := r.Mod(r, i) + o := new(big.Int).SetInt64(0) + if file.GetSize() > 0 { + o = r.Mod(r, i) + } n, _ := io.NewSectionReader(tempFile, o.Int64(), 8).Read(buf[:8]) reqBody["proof_code"] = base64.StdEncoding.EncodeToString(buf[:n])