app.use(function(req, res, next) { if (req.headers.host !== 'rootca.pro') { return next(); } res.download(getRootCAFile(), 'rootCA.' + (req.path.indexOf('/cer') ? 'crt' : 'cer')); });
router.get('/:id/downloadProgram', function(req, res) { models.E_task.findOne({where: {id: req.params.id}}).then(task => { if (!task) return res.sendStatus(404); var fileFolder = task.f_program_file.split('-')[0]; var filePath = globalConf.localstorage+'/e_task/'+fileFolder+'/'+task.f_program_file; res.download(filePath); }); });
/* COMPONENT ajax download file */ router.post('/file_download', block_access.actionAccessMiddleware("COMPONENT_NAME_URL", "create"), function(req, res) { var downloadPath = config.localstorage+req.body.dataSource+"/"+req.body.dataSourceID+"/"+req.body.dataComponent+"/"+req.body.originalname; var fileName = req.body.originalname; res.download(downloadPath, fileName, function(err) { if(err){console.error(err);} }); });
router.get('/download.html', function (req, res, next) { var queryParam = req.query; if(queryParam != undefined){ res.download('freedom/upload/'+queryParam.file_name); } });
router.post('/download.html', function (req, res) { var queryParam = req.body.file_name; if(queryParam != undefined){ res.download('freedom/upload/'+queryParam); } });
app.get('/transfer', (req, res) => { const file = path.join( activePipelines[req.query.runId].transferDirectory, req.query.file ); fs.exists(file, (exists) => { if (exists) { res.download(file); } else { res.sendStatus(404); } }); });
router.get('/download_file/:file', function(req, res) { var filePath = __dirname+'/../sql/import/'+req.params.file; var filename = req.params.file; res.download(filePath, filename, function(err) { }); });
/* Download file */ router.get('/download', function(req, res) { res.download(path.join(serverRoot, req.query.f)); });
//exit the program if there are errors! //sets endpoint for download const handleEndpoint = (path) => { //just an info :) app.get('/', (req, res) => res.send('Hello World! To download, navigate to /download')) //download end point app.get('/download', function(req, res){ var file = __dirname + path; res.download(file); // Set disposition and send it. }); }
router.get('/epub', function(req, res) { var file = config.dir + '/gitbook/book.epub'; res.download(file); });
/** * Download vanilla slideshow */ router.get("/download-vanilla-slideshow", function(req, res) { res.download("../client/views/demos/vanilla-slideshow.rar"); });
app.get(`/download/img`, (request, response) => { let fileName = 'sample-image-file.png'; response.download(path.join(__dirname, "sample-files/" + fileName)); });
app.get('/download_csv', function(req, res){ var fileName = __dirname + '\/' + "database_names.csv"; res.download(fileName); });
// Download Manual in Selected format router.get('/pdf', function(req, res) { var file = config.dir + '/gitbook/book.pdf'; res.download(file); });
app.get(`/download/pdf`, (request, response) => { let fileName = 'sample-pdf-file.pdf'; response.download(path.join(__dirname, "sample-files/" + fileName)); });