-
-
Save painkkiller/5b2a8cfb15943cc4e945921654c754ab 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
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