Fileupload component maxsize calculation #544
-
Hi Team, We have updated to primereact version 10.0.9, after updating we have an issue with the Fileupload component max size. we are passing 30000 it should be 30 KB, it was working fine before the update, but after an update, it is showing 29.297 KB, can you please check and resolve this? reference URL: https://stackblitz.com/edit/react-gwrmvd?file=src%2FApp.js |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
https://en.wikipedia.org/wiki/Kilobyte
and the PrimeReact code is using 1024. const formatSize = (bytes) => {
const k = 1024;
const dm = 3;
const sizes = localeOption('fileSizeTypes');
if (bytes === 0) {
return `0 ${sizes[0]}`;
}
const i = Math.floor(Math.log(bytes) / Math.log(k));
const formattedSize = parseFloat((bytes / Math.pow(k, i)).toFixed(dm));
return `${formattedSize} ${sizes[i]}`;
}; So basically 29.297 is over 30KB |
Beta Was this translation helpful? Give feedback.
https://en.wikipedia.org/wiki/Kilobyte
and the PrimeReact code is using 1024.