javascript - How to download a file from project/specific location using nodejs? -


this may dumb question lil confused, requirement should able download excel template on click event, thought put excel template in folder(docs) in backend code(instead of generating dynamically) , download that. possible, if yes how? using express , node.

it possible. use express framework. express can serve static files under '/public' folder. when user connect file, her/his browser download file. browser can view files online. example, chrome can open pdf files. if want force download file can use simple code;

app.get('/download', function(req, res){ var file = __dirname + '/upload-folder/dramaticpenguin.mov';   res.download(file); // set disposition , send it. }); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -