-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
feat(common): extend streamable-file header support #9240
feat(common): extend streamable-file header support #9240
Conversation
Provide option to specify additional headers when using StreamableFile. No need to access the native response option. BREAKING CHANGE: not specifying content-disposition header and StreamableFile option disposition would send header value 'null' instead of not sending the header at all. This changes to not sending the header if no value is specified. This commit closes issue nestjs#9229.
Pull Request Test Coverage Report for Build c59e21a2-4a17-496f-a5c6-8c268288f992
💛 - Coveralls |
any chance to make this feat backwards compatible? 👀 |
I found another problem with the current implementation of the @ApiOperation({ summary: 'Download a file.' })
@Get(':id')
downloadFile(
@Param('id') id: string,
@Req() request: Request,
// @Res() response: Response,
) {
return this.appService.download(id, request)
}
@ApiOperation({ summary: 'Download a file.' })
@Get(':id/broken')
downloadFileBroken(
@Param('id') id: string,
@Req() request: Request,
@Res() response: Response,
) {
return this.appService.download(id, request)
} As a result using the response object to define headers and the StreamableFile class for the stream is not an option. |
This is the expected behavior.
You shouldn't use both at the same time. |
@kamilmysliwiec Do you have an opinion on that "problem"? |
Ok.
I just looked it up again and tried with |
Provide option to specify content-length headers when using StreamableFile. No need to access the native response object. BREAKING CHANGE: not specifying content-disposition header and StreamableFile option disposition would send header value 'null' instead of not sending the header at all. This changes to not sending the header if no value is specified. This commit closes issue nestjs#9229.
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.
I think this looks good. If anyone wants to add additional headers to the response, from here they can use the @Res({ passthrough: true })
approach to get access to the response object and its headers
LGTM |
Provide option to specify additional headers when using StreamableFile.
No need to access the native response option.
BREAKING CHANGE: not specifying content-disposition header and
StreamableFile option disposition would send header value 'null'
instead of not sending the header at all.
This changes to not sending the header if no value is specified.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #9229
What is the new behavior?
More headers can be specified when using the StreamableFile class without needing to access the native response object.
Does this PR introduce a breaking change?
BREAKING CHANGE: not specifying content-disposition header and
StreamableFile option disposition would send header value 'null'
instead of not sending the header at all.
This changes to not sending the header if no value is specified.
Other information