diff --git a/src/app/components/fileupload/fileupload.ts b/src/app/components/fileupload/fileupload.ts index 8df13caae8b..561f1daf966 100755 --- a/src/app/components/fileupload/fileupload.ts +++ b/src/app/components/fileupload/fileupload.ts @@ -825,15 +825,18 @@ export class FileUpload implements AfterViewInit, AfterContentInit, OnInit, OnDe } formatSize(bytes: number) { - if (bytes == 0) { + const k = 1024; + const dm = 3; + const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + + if (bytes === 0) { return '0 B'; } - let k = 1000, - dm = 3, - sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], - i = Math.floor(Math.log(bytes) / Math.log(k)); - return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + const formattedSize = (bytes / Math.pow(k, i)).toFixed(dm); + + return `${formattedSize} ${sizes[i]}`; } onBasicUploaderClick() {