sails.js: download file in assets directory -


i create .xls file in assets/xls directory :

fs.writefilesync('./assets/xls/data.xls', xls, 'binary'); 

and want download file :

to file url :

var downloadlink = req.headers.host+'/xls/data.xls'; 

i not understant why have 404 error on url :
localhost:1337/xls/data.xls

this isn't recommended practice storing generated or user-uploaded files. assets folder intended site's front-end assets.

if want provide download links in app, you're encouraged save them in separate location , add controller action streams requested file client. allows add policies protect files, , avoids issues source control , grunt. see how authenticate access assets folder in sails.js example of such controller action.


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -