How to download a file with Node.js (without using third-party libraries)?

后端 未结 28 1254
逝去的感伤
逝去的感伤 2020-11-22 03:37

How do I download a file with Node.js without using third-party libraries?

I don\'t need anything special. I only want to download a file from a giv

28条回答
  •  情深已故
    2020-11-22 04:22

    Without library it could be buggy just to point out. Here are a few:

    • Can't handle http redirection, like this url https://calibre-ebook.com/dist/portable which is binary.
    • http module can't https url, you will get Protocol "https:" not supported.

    Here my suggestion:

    • Call system tool like wget or curl
    • use some tool like node-wget-promise which also very simple to use. var wget = require('node-wget-promise'); wget('http://nodejs.org/images/logo.svg');

提交回复
热议问题