stream MP3 through SailsJS framework
/** | |
* HomeController | |
* | |
* @module :: Controller | |
* @description :: Contains logic for handling requests. | |
*/ | |
module.exports = { | |
index: function (req,res) { | |
var fs = require('fs'); | |
var fullFilePath = '/Users/weston/visible/test.mp3'; | |
var stat = fs.statSync(fullFilePath); | |
res.writeHead(200, { | |
'Content-Type': 'audio/mpeg', | |
'Content-Length': stat.size | |
}); | |
var readStream = fs.createReadStream(fullFilePath); | |
readStream.pipe(res); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment