how to download a pdf file stored in a server in client side in node.js server

前端 未结 2 770
眼角桃花
眼角桃花 2021-02-10 02:29

How to allow a client to download a pdf file stored in a server using node.js.

Please, someone help me out with this code.

fs.readFile(\'temp/xml/user/us         


        
2条回答
  •  温柔的废话
    2021-02-10 03:22

    Express has 2 convenience methods available for sending files. The difference being:

    • Simply sending the file:

      res.sendfile('temp/xml/user/username.pdf');
      
    • Or with Content-Disposition to suggest saving to disk:

      res.download('temp/sml/user/username.pdf');
      

提交回复
热议问题