feat: Implement Fast Request feature with file upload and request management
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
const sizes = ['B', 'KB', 'MB', 'GB']
|
||||
|
||||
export const formatFileSize = (bytes) => {
|
||||
if (!bytes) {
|
||||
return `0 ${sizes[0]}`
|
||||
}
|
||||
|
||||
const k = 1024
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
const formattedSize = parseFloat((bytes / Math.pow(k, i)).toFixed(1))
|
||||
|
||||
return `${formattedSize} ${sizes[i]}`
|
||||
}
|
||||
Reference in New Issue
Block a user