There is currently an issue with Spring configuration where setting spring.servlet.multipart.maxFileSize to 15MB results in it being set as 15MiB.
So, propose changing the input units to MiB or adjusting the underlying logic to use 10 * 1000 * 1000, ensuring consistency between the user input and the actual configuration.
While using MB as the unit for file upload size in Spring configuration is quite common, it leads to confusion as the actual unit used is MiB, which is different.
Suggest the following solutions:
Change the input units from MB to MiB, or Modify the underlying Spring configuration logic to use 10 * 1000 * 1000, aligning user input with the actual configuration settings. These changes will help users to more accurately adjust their file upload settings. We kindly request a discussion to address this issue.
Thank you.
Comment From: wilkinsona
The Java ecosystem does not seem to make a clear distinction between MB and MiB and the former is often used when the latter would, arguably, have been more accurate. For example, the documentation for the java
CLI says the following for -Xmx
:
Specifies the maximum size (in bytes) of the heap. This value must be a multiple of 1024 and greater than 2 MB. Append the letter
k
orK
to indicate kilobytes,m
orM
to indicate megabytes, org
orG
to indicate gigabytes. The default value is chosen at runtime based on system configuration. For server deployments,-Xms
and-Xmx
are often set to the same value. The following examples show how to set the maximum allowed size of allocated memory to80 MB
using various units:
-Xmx83886080
-Xmx81920k
-Xmx80m
They document m
as indicating megabytes and show 80m
as being equivalent to 83886080
bytes. If you're distinguishing between megabytes and mebibytes then that's actually 80 mebibytes.
Comment From: snicoll
Thanks for the suggestion but there has been some discussion about that distinction in the past and we've decided to stick with what we have.