Skip to content

Commit

Permalink
Merge pull request #13473 from SoyDiego/13467-fileUpload-changed-base…
Browse files Browse the repository at this point in the history
…-1024

FileUpload: Added 1024 base unit conversion
  • Loading branch information
cetincakiroglu committed Aug 10, 2023
2 parents a613dd5 + 35c4287 commit 043660a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/app/components/fileupload/fileupload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 043660a

Please sign in to comment.