Skip to content

Fileupload component maxsize calculation #544

Closed Answered by melloware
RamaKrishna-CEVA asked this question in PrimeReact
Discussion options

You must be logged in to vote

https://en.wikipedia.org/wiki/Kilobyte

The term 'kilobyte' has traditionally been used to refer to 1024 bytes (210 B).[5][6][7] The usage of the metric prefix kilo for binary multiples arose as a convenience, because 1024 is approximately 1000.[8]

The binary interpretation of metric prefixes is still prominently used by the Microsoft Windows operating system.

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));

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by melloware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants