Created
September 17, 2014 14:41
-
-
Save thebergamo/f93cbdd529f01c8ee4ad 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
var file = __dirname + '/../upload/'+ req.payload.code+'.jpg'; | |
fs.exists(file, function(exists){ | |
if(!exists) | |
res(Boom.notFound('Image not found')); | |
var fd = fs.openSync(file, 'r'); | |
var end = new Buffer(4); | |
fs.readSync(fd, end, 0, 4, 0); | |
var name = new Buffer(end.readUInt32LE(0)); | |
fs.readSync(fd, name, 0, end.readUInt32LE(0), 4); | |
fs.closeSync(fd); | |
fs.createReadStrean(file, { | |
start: end.readUInt32LE(0) + 4 | |
}).pipe(res); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment