Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var fs = require('fs');
  2. const GrowingFile = require('growing-file')
  3.  
  4. function serveAudio(req, res) {
  5.  
  6.     var file = req.query.audio;
  7.     var path = "audioFiles/" + file + ".mp3";
  8.     }
  9.     if (fs.existsSync(path)) {
  10.         var options = {
  11.             timeout: 3000,
  12.             interval: 100,
  13.             startFromEnd: false
  14.         }
  15.         var file = GrowingFile.open(path, options);
  16.         file.pipe(res);
  17.     } else {
  18.         res.send("error");
  19.     }
  20. }
  21. module.exports = { serveAudio }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement