I am using spring boot for uploading files. The files sizes are usually about 2GB and we cannot use the default spring boot StandardServletMultipartResolver
or CommonsMultipartResolver
since the server have limited resource (disk space) or memory for buffering. So we would like to get the file inputsteam and store the file directly to the cloud storage.
I know spring boot has the multipart.enabled
property so I can set it to false to skip the spring MultipartResolver
. But this disables multipart globally. Does any one know if there is a way to disable multipart by controller/method?
If you enable
resolve-lazily
, the result is exactly what I think you're asking for.Now you can write controllers with either form of signature.
Pre-parsing by the built-in multipart resolver...
Or post-parsing (which you can parse yourself)...
This shows how it can be done :
springboot-large-streaming-file-upload-using-apache-commons-fileupload
Look at the answer of balajeerc