Skip to content

Instantly share code, notes, and snippets.

@tsvetomir
Last active August 19, 2020 16:08
Show Gist options
  • Save tsvetomir/9badf70b7626b772554d791bbf2f14c0 to your computer and use it in GitHub Desktop.
Save tsvetomir/9badf70b7626b772554d791bbf2f14c0 to your computer and use it in GitHub Desktop.
Kendo UI file save proxy (Express)
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