mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
[FEATURE] - Adding fileSize in backup model in order to display it.
This commit is contained in:
@@ -15,4 +15,14 @@ export function isUUID(str: string) {
|
||||
|
||||
export function isImportedFilename(name: string): boolean {
|
||||
return name.startsWith("imported_");
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number | null, decimals = 2): string {
|
||||
if (!bytes) return "N/A";
|
||||
if (bytes === 0) return "0 Bytes";
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
||||
}
|
||||
Reference in New Issue
Block a user