Skip to content

Instantly share code, notes, and snippets.

@tsvetomir
Last active August 19, 2020 16:08
Show Gist options
  • Select an option

  • Save tsvetomir/9badf70b7626b772554d791bbf2f14c0 to your computer and use it in GitHub Desktop.

Select an option

Save tsvetomir/9badf70b7626b772554d791bbf2f14c0 to your computer and use it in GitHub Desktop.

Revisions

  1. tsvetomir revised this gist Aug 19, 2020. No changes.
  2. tsvetomir revised this gist Aug 19, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,8 @@ 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);
  3. tsvetomir created this gist Aug 19, 2020.
    20 changes: 20 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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');

    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}`)
    });