Last active
August 19, 2020 16:08
-
-
Save tsvetomir/9badf70b7626b772554d791bbf2f14c0 to your computer and use it in GitHub Desktop.
Kendo UI file save proxy (Express)
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 bodyParser = require('body-parser'); | |
const app = express(); | |
const port = 7569; | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.post('/', (req, res) => { | |
const { fileName, contentType, base64 } = req.body; | |
const content = Buffer.from(base64, 'base64'); | |
console.log(`Saving ${fileName} (${content.length} bytes)`); | |
res.set('Content-Type', contentType); | |
res.set('Content-Length', content.length); | |
res.set('Content-Disposition', 'attachment; filename=' + fileName); | |
res.send(content); | |
}); | |
app.listen(port, () => { | |
console.log(`Kendo UI Proxy listening at http://localhost:${port}`) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment