-
-
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(core): add file send capability #5278
Conversation
Pull Request Test Coverage Report for Build 0646adc6-5d7d-4efd-a4d6-05e8e76f2a14
💛 - Coveralls |
I've just realized that this may actually introduce a breaking change. Very rare case, but what if someone has a class that contains a custom To avoid a breaking change, perhaps we can define a new, dedicated wrapper class that you could use as follows |
Oh wow, very good catch, hadn't thought of that. As Fastify already handles streams and buffers, would this change only affect Express, or should we make a similar change (using this new class) for Fastify as well, to keep parity between the engines? |
Well, I guess we can just add a new wrapper class and mention it in the docs as a "cross-platform" supported solution. As you pointed out above, since Fastify already handles streams and buffers, using this class won't be required (but still, it gives some ++ in case one wants to switch to another HTTP engine at some point). |
Circling back around to this: what about Also, where in the code would this go? I assume |
We might need a new folder for this. I'm open to any ideas. |
All right, I'll get back to work on this PR when I've got some time and we can discuss what changes might need to be made when I update the PR |
b46fe47
to
49cc0ad
Compare
All right, added in the |
Looks great! @jmcdo29 can you please resolve conflicts + create a PR to the docs with this feature? I'm not sure what would be the best chapter to add it though (maybe FIle Upload although the name may be a little bit confusing) |
What if we add a section to the |
Fastify has the built in capbility to send files without any extra code. Express can send files via `stream.pipe(res)` if the file is a stream, and as such, the `Content-Type` header is set to `application/octet-stream` in the ExpressAdapter if a stream or Buffer is detected. fix nestjs#5263
The new `StreamableFile` class allows for users to create an easy to consume file to send back to the client side. Both `ExpressAdapter` and `FastifyAdapter` have been updated to accomodate for this new class.
49cc0ad
to
1c8ee54
Compare
Merge conflicts are fixed. Kafka test failed (as usual) |
cf62063
to
149bf82
Compare
LGTM, thanks! |
Fastify has the built in capbility to send files without
any extra code. Express can send files via
stream.pipe(res)
if the file is a stream, and as such, the
Content-Type
header is set toapplication/octet-stream
in the ExpressAdapter if a stream or Buffer is detected.
fix #5263
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?
Files are not currently supported by Express and Fastify
Issue Number: #5263
What is the new behavior?
Fastify and Express Adapters now both support sending files via streams and Buffers.
Does this PR introduce a breaking change?
Other information