Storage: Add basic file upload management (#50638)

This commit is contained in:
Ryan McKinley
2022-07-05 10:53:41 -07:00
committed by GitHub
parent 4a76436be2
commit 4a00c7ebde
25 changed files with 1105 additions and 174 deletions

View File

@ -117,3 +117,17 @@ func Capitalize(s string) string {
r[0] = unicode.ToUpper(r[0])
return string(r)
}
func ByteCountSI(b int64) string {
const unit = 1000
if b < unit {
return fmt.Sprintf("%d B", b)
}
div, exp := int64(unit), 0
for n := b / unit; n >= unit; n /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f %cB",
float64(b)/float64(div), "kMGTPE"[exp])
}