DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Discussion on: Streaming Video with Nestjs

Collapse
 
micalevisk profile image
Micael Levi L. C. • Edited on

cool! another way would be:

@Get()
@Header('Content-type', 'video/mp4')
@Header('Content-Disposition', 'inline; filename="video.mp4"')
getFile(): StreamableFile {
  const file = createReadStream(join(process.cwd(), 'videos/video.mp4'));
  return new StreamableFile(file);
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
xgeek116 profile image
rm116

@micalevisk How a frontend client like react will receive the StreamableFile(file) ? If it was a large PDF file for example ? is there a way to send it / receive it piece by piece ?

Collapse
 
savi8sant8s profile image
SΓ‘vio Santos

Even better. very cool!!