-
Notifications
You must be signed in to change notification settings - Fork 38.8k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
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. |
|
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 As @rstoyanchev pointed out, the Return Values section is the best place to address this, I'm gonna add a I also used |
|
@verils, I don't think we should avoid documenting returning 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. |
|
@rstoyanchev Yes, I agree that. So I'll just deal with the return type list first. |
Signed-off-by: verils <verils@qq.com>
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?