Improved uploader
This commit is contained in:
15
scripts/Utils/bytesHumanReadable.ts
Normal file
15
scripts/Utils/bytesHumanReadable.ts
Normal file
@ -0,0 +1,15 @@
|
||||
export function bytesHumanReadable(fileSize: number): string {
|
||||
let unit = "bytes"
|
||||
|
||||
if(fileSize >= 1024) {
|
||||
fileSize /= 1024
|
||||
unit = "KB"
|
||||
|
||||
if(fileSize >= 1024) {
|
||||
fileSize /= 1024
|
||||
unit = "MB"
|
||||
}
|
||||
}
|
||||
|
||||
return `${fileSize.toFixed(0)} ${unit}`
|
||||
}
|
Reference in New Issue
Block a user