Spring Framework 是否支持多部分请求中的流模式 [英] Does Spring Framework support streaming mode in multipart requests

查看:25
本文介绍了Spring Framework 是否支持多部分请求中的流模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 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?

推荐答案

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

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.

或者,您可以使用 Spring 注释编写控制器.如果您将其添加为方法控制器参数之一,Spring 将注入 ServletRequest.之后,您可以使用Apache 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.

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

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.

这篇关于Spring Framework 是否支持多部分请求中的流模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆