Hi,
I've encountered an issue where the uploaded file size differs from the local file size.
This is the uploaded file size:
And this is the local file size:
Notice the message indicates 8.4 MB, but the actual file size is 8.1 MB.
How can I resolve this?
I also found a post on Pqina's GitHub discussing a similar problem, but I'm unsure where to modify the code in the Forge component to fix this.
Thank you.
hi, @Ronaldo David
you can set the maximum file size in configuration property of widget
Hi Vikram,
We have set our Maximum File Size to 5MB but notice that the message for the uploaded file size is different with the local file size. The user might get confused why the uploaded file seems bigger vs the one in their local storage.
Hi Ronaldo,
Well done for identifying this one and finding that discussion.
I could expose the FileSizeBase configuration option. However, that won't solve the problem on both Windows and Mac.
The problem is that Windows and Mac use different calculations to display the file size (mebibyte versus megabyte).
Kind regards,
Stuart
Hi Stuart,
Thank you for your quick response. I hope we can make the FileSizeBase configuration option available. In my situation, our application is run on company-provided workstations using the Windows operating system.
Is there a quick manual solution I can apply to our Forge asset to set the FileSizeBase?
If you're really brave (of course you are! :) ), you could edit the filePondUploadPlugin script.
Add fileSizeBase: 1024 after line 551:
I have added the code inside filePondUploadPlugin but the result is still the same.
The text should be 8.1 MB. Is there another way to modify the fileSizeBase?
Thank you for your patience.
Hi Ronaldo, I will have to investigate.
Are you using the latest version of the forge component? The latest version uses version 4.30.4, however, the previous version won't have fileSizeBase in its configuration.
Let me know if you are on the latest version, and if so I'll investigate. It might take me a week to have time to properly investigate, but I'll have a look for you.
I updated to latest version and it started working but the display is still different from what I expect.
Also the Maximum file size display changed to 4.8 MB which should be 5 MB.
Ok great. The problem is this component just integrates the library, so whatever the library does it will do.
What happens if you specify 5.12MB as the maximum file size? (5 x 1024/1000)
I hope this helps.
I tried setting it to 5.12 but it is still the same. I noticed that it is still 5 MB in the console log even after setting it to 5.12. Is it possible that it is rounding off to 5?
Thanks.
Ah yes, it is removing the decimal places. If you remove the Math.floor that could work.
This was the result after removing the Math.Floor.