Skip to content

Conversation

@verils
Copy link

@verils verils commented Nov 5, 2025

I've updated the documentation to indicate that a ResponseEntity can be returned from a WebFlux controller.

On a separate note, since file uploads and downloads are common requirements in the Spring framework, I believe it would be beneficial to create a dedicated page to guide developers through the process. I'd be happy to create one. What are your thoughts?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 5, 2025
Copy link
Contributor

@rstoyanchev rstoyanchev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a worthwhile improvement to consider, but not how I would address it.

Both Spring MVC and WebFlux list supported return types. Neither of them mentions Resource explicitly, but that has more to do with the supported codecs (WebFlux) and message converters (WebMvc).

My suggestion is to begin by adding a subsection on Resources under Codecs and Message Converters. Then this can be mentioned as well as referenced from the list of return values for ResponseEntity and @ResponseBody.

Let me know if you plan to update the PR along those lines, or if you only update the WebFlux side, we can do the rest.

@rstoyanchev
Copy link
Contributor

On a separate note, since file uploads and downloads are common requirements in the Spring framework, I believe it would be beneficial to create a dedicated page to guide developers through the process.

We have Multipart Content for WebFlux and similar for WebMvc that cover uploads. Renaming that to Multipart Uploads, and creating another on Multipart Downloads would be fine.

@rstoyanchev rstoyanchev added type: documentation A documentation task in: web Issues in web modules (web, webmvc, webflux, websocket) status: waiting-for-feedback We need additional information before we can continue labels Nov 18, 2025
@verils
Copy link
Author

verils commented Nov 18, 2025

Initially, the issue I encountered was that I didn't know how to handle content downloads in WebFlux, as there was no clear explanation in the documentation. I did some search online and finally found out that returning ResponseEntity<Flux<DataBuffer>> is the best option for me. Therefore, my main goal is to clarify it, the DataBuffer section is very close to the truth but isn't explicit enough.

As @rstoyanchev pointed out, the Return Values section is the best place to address this, I'm gonna add a Flux<DataBuffer> line to that table.

I also used Resource for a while but encountered a side effect: the ResourceHttpMessageWriter (in WebFlux) and the ResourceHttpMessageConverter (in WebMvc) automatically override the response's Content-Type with media type from the Resource. This can break an application/octet-stream download, and this behavior should also be documented.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 18, 2025
@rstoyanchev
Copy link
Contributor

@verils, I don't think we should avoid documenting returning Resource as a way to handle downloads just because of an issue you ran into. The issue should be considered to decide whether it is intentional, a limitation, something that needs fixing, and so on.

I will say briefly that if the returned ResponseEntity has the content-type set then I would expect it to get used. However, I would also want to know why the content type of the resource isn't the right one to begin with. This is best discussed in a separate issue.

@verils
Copy link
Author

verils commented Nov 19, 2025

@rstoyanchev Yes, I agree that.

So I'll just deal with the return type list first.

@verils verils changed the title Add note on returning ResponseEntity<Resource> for file content in do… Add return type description Nov 19, 2025
Signed-off-by: verils <verils@qq.com>
@rstoyanchev rstoyanchev self-assigned this Nov 19, 2025
@rstoyanchev rstoyanchev changed the title Add return type description Improve documentaton on controller return values for file downloads Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: web Issues in web modules (web, webmvc, webflux, websocket) status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on type: documentation A documentation task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants