Created
October 31, 2018 10:51
-
-
Save ufocoder/30ee6c335b4d4e2debce3f2fe57a3b81 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import { readFile } from "fs"; | |
| router.get("/some-file", function (req, res) { | |
| const url = "./data/some-file.ext"; | |
| readFile(url, function (err, file) { | |
| if (err) { | |
| res.writeHead(404); | |
| res.end(); | |
| } else { | |
| res.writeHead(200, { "Content-Type": "application/octet-stream" }); | |
| res.write(file); | |
| res.end(); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment