Last active
June 28, 2018 08:43
-
-
Save energizer91/ce99be797992c7924392f2476a7d239d 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
const express = require('express'); | |
const app = express(); | |
app.post('/file', (req, res, next) => { | |
let first = true; | |
req.on('data', chunk => { | |
if (!first) { | |
return; | |
} | |
console.log('file extension is', chunk.slice(1, 4).toString()); | |
console.log('PNG width is', chunk.readUIntBE(16, 4)); | |
console.log('PNG height is', chunk.readUIntBE(20, 4)); | |
first = false; | |
}); | |
req.on('end', () => { | |
res.send('done'); | |
}) | |
req.on('error', next); | |
}); | |
app.use((err, req, res, next) => { | |
res.send('error' + JSON.stringify(err)); | |
}); | |
app.listen('3000'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment