Skip to content

Commit

Permalink
Merge pull request #245 from AntoineGrandchamp/master
Browse files Browse the repository at this point in the history
πŸ› Use binary system to convert bytes to kbs and mbs
  • Loading branch information
Mattia Panzeri authored Sep 15, 2020
2 parents 89ea34f + 9467f81 commit 000764e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ export function isImage(file) {

export function convertBytesToMbsOrKbs(filesize) {
let size = '';
// I know, not technically correct...
if (filesize >= 1000000) {
size = (filesize / 1000000) + ' megabytes';
} else if (filesize >= 1000) {
size = (filesize / 1000) + ' kilobytes';
if (filesize >= 1048576) {
size = (filesize / 1048576) + ' megabytes';
} else if (filesize >= 1024) {
size = (filesize / 1024) + ' kilobytes';
} else {
size = filesize + ' bytes';
}
Expand Down

0 comments on commit 000764e

Please sign in to comment.