node.js - Javascript Download CSV File -


i trying create button on website allow user downlaod .csv file. have site hit server , server generates string of text in format of csv file. not sure proceed. save string file on server , send file client (i prefer not create files on server side) or send client string of text , create file on client side? button function user expect download button work (ie given choice save file , progress bar shows progress f file download)

i using nodejs , express on server side.

once file generated put link file location in page:

<a href="filename.xxx" target="_blank">clickable text</a> 

the browser know how handle , prompt user save file. once user specifies file downloaded user's computer.

if want create file in memory , send user if using asp.net mvc:

public filestreamresult myfunction(/*your parms*/) {     system.io.memorystream stream = functionthatcreatesmycalendarstream();     //you may need stream.position = 0 here depending on state above funciton leaves stream in.     //stream.position = 0;     filestreamresult result = new filestreamresult(stream, "text/csv");     result.filedownloadname = "myfiledownloadname.csv";     return result; }  

edit: if using node.js @ post - nodejs send file in response


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -