I am trying to get the content of MultipartFile
, which is obtained through MultipartHttpServletRequest.getFile()
.
There are 2 functions in MultipartFile
:
bytes[] getBytes() ()
InputStream getInputStream()
What is the most efficient way to get the content? (Which method would you use?)
Only difference is that with getBytes() the data has already been read from the stream, whereas with getInputStream() you will still have to read the data.
What you use depends on what you want to do with the content. If its an image that you just want to write out to disk, then getBytes() would be best, but if it is Text that you want to parse and do something with, then getInputStream() might be better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With