openedx / paragon

💎 An accessible, theme-ready design system built for learning applications and Open edX.

Home Page:https://paragon-openedx.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] Inaccurate file size calculations in Dropzone

monteri opened this issue · comments

I encountered a bug when used maxSize prop on the Dropzone component. I passed 20 * 1024 * 1024 that equals to 20MB. When I uploaded a file of size 20.3MB the error state didn't occurred. I investigated deeper and found out that 20 * 1024 * 1024 = 20971520 that is bigger than 20312736 (the file size). image

In that time the component displays the error correctly when I pass a file of 80MB. It says that File must be less than 20MB..

As a work around I passed 20 * 1000 * 1000 and obtained the desired behavior of the error state but the alert displays inaccurate value of 19.07MB.

image

It seems like on your local machine filesizes are calculated using decimal instead of binary

image

Where as react-dropzone and the utils to format byes in a user friendly format use binary instead of decimal