Spring框架是否支持多部分请求中的流模式

发布于 2024-10-10 02:12:16 字数 326 浏览 0 评论 0 原文

我在 Spring 文档 中找不到任何指示它支持在处理多部分请求的 MultipartHttpServletRequest 对象中以流模式读取文件。

Apache Commons 框架 中也可以采用类似的方式。

Spring 是否支持它?

I coulnd't find any indication in Spring documentation that it support read of files in streaming mode in its object MultipartHttpServletRequest that handle multipart requests.

in similar way that is possible in Apache Commons framework.

is it supported in Spring at all?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桃酥萝莉 2024-10-17 02:12:16

是的,看看 此处。你的 Spring API 太旧了。另外,Streaming模式与Spring无关。这是您的 servlet 容器或服务器的能力。现在大多数服务器都支持流模式。 Servlet 在从请求中获取标头后将立即开始执行请求。您可以继续发送请求正文的流(例如多部分数据)。但只有当请求发送完毕后才能完整地进行解析。这与 Apache Common FileUpload 相同。

或者,您可以使用 Spring 注释编写控制器。如果您将 ServletRequest 添加为方法控制器参数之一,Spring 将注入 ServletRequest。之后,您可以使用 Apache FileUpload 进行多部分解析。

您不能进行选择性解析,因为无论如何请求都必须完全发送到服务器。这是Http的限制。我问了问题几天前。

Yes, have a look here. Your Spring API is far too old. Also, the Streaming mode has nothing to do with Spring. It is the ability of your servlet container or your server. Most server now support the streaming mode. Servlet will start performing the request as soon as it got the header from your request. You can continue to send out the stream of your request body (e.g. multipart data). However, the parsing can only be performed completely when the request is sent fully. This is the same as Apache Common FileUpload.

Alternatively, you can write a controller using Spring annotation. Spring will inject the ServletRequest if you add that as one of your method controller arugument. After that, you can use Apache FileUpload to do multipart parsing.

You can not do selective parsing since the request must be fully sent to server no matter what. It is the limit of Http. I asked the question a few day ago.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文