fix(139): upload failed (#2950)

fix: The file size is exceeded and cannot be uploaded
fix: File name has special characters, signature fails
improve: optimize memory usage
Signed-off-by: aimuz <mr.imuz@gmail.com>

Signed-off-by: aimuz <mr.imuz@gmail.com>
This commit is contained in:
aimuz
2023-01-08 16:31:00 +08:00
committed by GitHub
parent 40ef233d24
commit 99a186d01b
3 changed files with 51 additions and 34 deletions

View File

@ -105,3 +105,23 @@ type PutResult interface {
}
type UpdateProgress func(percentage int)
type Progress struct {
Total int64
Done int64
up UpdateProgress
}
func (p *Progress) Write(b []byte) (n int, err error) {
n = len(b)
p.Done += int64(n)
p.up(int(float64(p.Done) / float64(p.Total) * 100))
return
}
func NewProgress(total int64, up UpdateProgress) *Progress {
return &Progress{
Total: total,
up: up,
}
}