How to stream files
See original GitHub issueHi, 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?
export default defineEventHandler((event) ->
const stream = fs.createReadStream(path);
stream.pipe(event.res);
)
or
const stream = fs.createReadStream(path);
sendStream(event, stream);
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Stream (or sync) Drive files to users' computers - Google Help
To access Drive files and keep them in sync on all your devices, use Google Drive for desktop. This application lets you stream...
Read more >How to stream large .mp4 files? - GeeksforGeeks
How to stream large .mp4 files? · Open terminal · mkdir <project name> · cd <project name> · npm init -y · Open...
Read more >How to stream files from OBS | Videolinq Help Center
Click on the OBS "Settings" tab (lower right side) and enter the OBS stream configuration area. On the left navigation bar click on...
Read more >How to stream local files to your Chromecast or Android TV
The first thing you want to do is download the app, Videostream. You can do that here. send files to your chromecast videostream...
Read more >How to stream your personal video collection to any device
Fire up a Roku player, for example, load up the default media player, and you should see your files ready to be streamed....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@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
sendStream
support is not universal yet.