用于文件上传的 Servlet 3.0 流 api
新的Servlet 3.0 API为我们提供了解析多部分表单数据的便捷方法。但它将上传文件的内容存储在文件系统或内存中
Servlet 3.0 是否有流 API?
类似于Commons FileUpload。我必须直接从 InputStream 写入内容并写入另一个 OutputStream 并且我不想将临时文件内容存储在磁盘或内存中
New Servlet 3.0 API provide us with convenient way to parse multi-part form data. But it stores content of uploaded files in file system or in memory
Is there streaming API for Servlet 3.0 ?
Something like Commons FileUpload. I have to write content directly from InputStream and write to another OutputStream adn I don't want to store temporary file content in disc or memory
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我曾经用过它来做类似的事情,尽管不是用 servlet。它不会用数据填满你的记忆。希望有帮助:
http://code.google.com/p/io-tools/wiki/Tutorial_EasyStream
I used this once for something similar, though not with servlets. It doesn't fill up your memory with data. Hope it helps:
http://code.google.com/p/io-tools/wiki/Tutorial_EasyStream
查看 Servlet 3.0 规范,可能无法实现流式传输
因此必须预先解析请求,以便所有非文件部分都可以作为 HttpServletRequest 参数公开。
如果您需要流式传输,则必须使用第三方库。
Looking at the Servlet 3.0 spec it may not be possible to have a streaming implementation
So the request must be parsed up front so that all the non-file parts can be exposed as HttpServletRequest parameters.
You have to use third party libraries if you need streaming.