use 1000 instead of 1024 to show correct fileSize

This commit is contained in:
Eduard Heimbuch
2019-09-05 08:09:49 +02:00
parent 231d4d8810
commit d2ad6eb2f6

View File

@@ -12,9 +12,9 @@ class FileSize extends React.Component<Props> {
}
const units = ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"];
const i = Math.floor(Math.log(bytes) / Math.log(1024));
const i = Math.floor(Math.log(bytes) / Math.log(1000));
const size = i === 0 ? bytes : (bytes / 1024 ** i).toFixed(2);
const size = i === 0 ? bytes : (bytes / 1000 ** i).toFixed(2);
return `${size} ${units[i]}`;
}