Attachment size, changed calculation to npm filesize (Version Info)

This commit is contained in:
Martin Filser 2022-04-29 12:02:51 +02:00
parent 464bc2f87b
commit 20c2679dc8
2 changed files with 18 additions and 21 deletions

View file

@ -1,4 +1,5 @@
import { TAPi18n } from '/imports/i18n';
const filesize = require('filesize');
BlazeComponent.extendComponent({
onCreated() {
@ -39,12 +40,8 @@ BlazeComponent.extendComponent({
return parseFloat(number).toFixed(2);
},
bytesToSize(bytes) {
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes === 0) {
return '0 Byte';
}
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10);
return `${Math.round(bytes / Math.pow(1024, i), 2)} ${sizes[i]}`;
fileSize(size) {
const ret = filesize(size);
return ret;
},
}).register('statistics');