Created
June 24, 2021 23:20
-
-
Save asoltys/a7ee61da29a233c3977ac59f842e68bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/file/:name', function (request, reply) { | |
let type = 'application/json'; | |
const { name } = request.params; | |
const stream = fs.createReadStream(`file/${name}`); | |
if (name.includes('m3u8')) type = 'application/vnd.apple.mpegurl'; | |
if (name.includes('ts')) type = 'video/MP2T'; | |
reply.header('Content-Type', type).send(stream.pipe(transform)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment