-
Notifications
You must be signed in to change notification settings - Fork 237
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
How to stream files #93
Comments
I have the same issue with Nuxt 3 and asked for help at https://github.com/nuxt/framework/discussions/4299 Found this thread created 22 hours ago while going to ask the same on |
I found solution by using playground and checking code. Solution is super simple, sendStream has to be returned directly
In my case if you have promise first it's working as well
KISS, but generally would be good to add it to documentation before some other people run into this issue as streaming files is common exercise. |
Would love to see a PR to https://v3.nuxtjs.org/guide/features/server-routes#handling-requests-with-body to add an example about it 💚 |
@atinux I've even prepared code for h3 Readme.md and Nuxt repo as well with samples, but apparently I have some access problem. Will try to push it later. |
Nuxt PR: nuxt/framework#4401 |
@atinux We should probably start adding examples directly to h3 docs. Otherwise, we will end up with fragmented documentation and outdated info for utils. Also, consider |
How do I send a piped file? import PDFDocument from 'pdfkit'
import { sendStream } from 'h3'
export default defineEventHandler(async (event) => {
const doc = new PDFDocument()
doc.pipe(event.res)
doc.text('Test')
doc.end()
return sendStream(event, event.res)
}) |
how to stream text from a variable and not in a file? |
Hi, I am trying to stream files from local disc (for a reason it's not served as static).
I tried to use sendStream or send it directly to pipe but each time I get 404. Documentation is not mentioning too much how to use streams. How to use it correctly with h3?
or
The text was updated successfully, but these errors were encountered: