Skip to content

Commit

Permalink
fix conversion from Bytes to GigaBytes
Browse files Browse the repository at this point in the history
When an image with exactly 1MB is used, the fileSizeReadable ouput contains wrong value for file size (instead of 1MB it returns 2MB which is wrong)
  • Loading branch information
CiprianDraghici authored Mar 2, 2020
1 parent 20063d2 commit 234077e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ class Files extends React.Component {
}

fileSizeReadable (size) {
if (size >= 1000000000) {
return Math.ceil(size / 1000000000) + 'GB'
} else if (size >= 1000000) {
return Math.ceil(size / 1000000) + 'MB'
} else if (size >= 1000) {
return Math.ceil(size / 1000) + 'kB'
if (size >= 1073741824) {
return Math.ceil(size / 1073741824) + 'GB'
} else if (size >= 1048576) {
return Math.ceil(size / 1048576) + 'MB'
} else if (size >= 1024) {
return Math.ceil(size / 1024) + 'kB'
} else {
return Math.ceil(size) + 'B'
return Math.ceil(size) + 'B'
}
}

Expand Down

0 comments on commit 234077e

Please sign in to comment.