Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve documentaton on controller return values for file downloads#35760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
verils wants to merge1 commit intospring-projects:main
base:main
Choose a base branch
Loading
fromverils:main

Conversation

@verils
Copy link

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-issuesspring-projects-issues added the status: waiting-for-triageAn issue we've not yet triaged or decided on labelNov 5, 2025
Copy link
Contributor

@rstoyanchevrstoyanchev left a comment
edited
Loading

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 listsupported return types. Neither of them mentionsResource 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 onResources underCodecs andMessage Converters. Then this can be mentioned as well as referenced from the list of return values forResponseEntity 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 haveMultipart Content for WebFlux and similar for WebMvc that cover uploads. Renaming that to Multipart Uploads, and creating another on Multipart Downloads would be fine.

@rstoyanchevrstoyanchev added type: documentationA documentation task in: webIssues in web modules (web, webmvc, webflux, websocket) status: waiting-for-feedbackWe need additional information before we can continue labelsNov 18, 2025
@verils
Copy link
Author

verils commentedNov 18, 2025
edited
Loading

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 returningResponseEntity<Flux<DataBuffer>> is the best option for me. Therefore, my main goal is to clarify it, theDataBuffer section is very close to the truth but isn't explicit enough.

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

I also usedResource for a while but encountered a side effect: theResourceHttpMessageWriter (in WebFlux) and theResourceHttpMessageConverter (in WebMvc) automatically override the response's Content-Type with media type from theResource. This can break anapplication/octet-stream download, and this behavior should also be documented.

@spring-projects-issuesspring-projects-issues added status: feedback-providedFeedback has been provided and removed status: waiting-for-feedbackWe need additional information before we can continue labelsNov 18, 2025
@rstoyanchev
Copy link
Contributor

@verils, I don't think we should avoid documenting returningResource 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 commentedNov 19, 2025
edited
Loading

@rstoyanchev Yes, I agree that.

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

@verilsverils changed the titleAdd note on returning ResponseEntity<Resource> for file content in do…Add return type descriptionNov 19, 2025
Signed-off-by: verils <verils@qq.com>
@rstoyanchevrstoyanchev self-assigned thisNov 19, 2025
@rstoyanchevrstoyanchev changed the titleAdd return type descriptionImprove documentaton on controller return values for file downloadsNov 19, 2025
@rstoyanchevrstoyanchev removed status: waiting-for-triageAn issue we've not yet triaged or decided on status: feedback-providedFeedback has been provided labelsDec 1, 2025
@rstoyanchevrstoyanchev added this to the7.0.2 milestoneDec 1, 2025
@rstoyanchevrstoyanchev modified the milestones:7.0.2,7.0.xDec 10, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@rstoyanchevrstoyanchevrstoyanchev requested changes

Assignees

@rstoyanchevrstoyanchev

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: documentationA documentation task

Projects

None yet

Milestone

7.0.x

Development

Successfully merging this pull request may close these issues.

3 participants

@verils@rstoyanchev@spring-projects-issues

[8]ページ先頭

©2009-2025 Movatter.jp