获取MultipartFile的内容
我试图获取 MultipartFile
的内容,它是通过 MultipartHttpServletRequest.getFile()
获得的。
MultipartFile
中有2个函数:
bytes[] getBytes() ()
InputStream getInputStream()
获取内容最有效的方法是什么? (你会使用哪种方法?)
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?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
唯一的区别是,使用 getBytes() 时,数据已经从流中读取,而使用 getInputStream() 时,您仍然需要读取数据。
您使用什么取决于您想要对内容执行什么操作。如果您只想将其写入磁盘的图像,那么 getBytes() 会是最好的,但如果您想解析并执行某些操作的文本,那么 getInputStream() 可能会更好。
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.