res.setHeader('Content-Type', 'application/pdf')
this will automatically download or show the file in pdf format directly.
If We want to change name of the file if we are getting random names from the ID we got which gives us a random number always we can do that just by entering this small code
res.setHeader('Content-Disposition', 'attachment; filename="' + invoiceName + '"')
attachment will open our file in new window
if we use inline instead of attachment our file will open in the same tab. and it will not start downloading in this but in case of attachment it will automatically start downloading our file.
res.setHeader('Content-Disposition', 'inline; filename="' + invoiceName + '"')
Now Restricting our File Access for other Clients
Comments