On 20/01/18 10:07, [email protected] wrote:
> Can someone explain what JavaScript should be in the server to catch the
> 'download' command and return the specified file? What should the
> "socket.on(???, downloadFile);" look like? What's the correct way to
> return the file so the client browser correctly saves it?

It looks much the same as what it does to display your index page, but
instead of setting "Content-Type: text/html" and dumping HTML, it sets
"Content-Type: application/octet-stream" and dumps binary data.

You haven't told us what HTTP server you're using, so it's a little
difficult to say exactly how you do it.  One commonly used one for this
task is Express…

https://expressjs.com/en/starter/hello-world.html gives an example of
doing more or less what you've done… if you were to modify that front
page with a hyperlink, the extra code would look like this:

app.get('/mydata.csv', function (req, res) {
        res.set('Content-Type', 'application/octet-stream');
        res.send('your CSV data');
});
-- 
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
  ...it's backed up on a tape somewhere.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/ac0c7271-e36a-db67-b1d3-c6207da20f6d%40longlandclan.id.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to