大家好我想在我的项目中使用Multi downloader module。我检查了git链接,但没有关于如何使用此模块的示例。我检查了this link作为示例并在我的项目中使用,但它显示在错误之下。
createDownload is not a constructor
TypeError: createDownload is not a constructor
at D:\Project\Mt-downloader-test-master\routes\index.js:16:19
at Layer.handle [as handle_request] (D:\Project\Mt-downloader-test-master\node_modules\express\lib\router\layer.js:95:5)
at next (D:\Project\Mt-downloader-test-master\node_modules\express\lib\router\route.js:131:13)
at Route.dispatch (D:\Project\Mt-downloader-test-master\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (D:\Project\Mt-downloader-test-master\node_modules\express\lib\router\layer.js:95:5)
at D:\Project\Mt-downloader-test-master\node_modules\express\lib\router\index.js:277:22
at Function.process_params (D:\Project\Mt-downloader-test-master\node_modules\express\lib\router\index.js:330:12)
at next (D:\Project\Mt-downloader-test-master\node_modules\express\lib\router\index.js:271:10)
at Function.handle (D:\Project\Mt-downloader-test-master\node_modules\express\lib\router\index.js:176:3)
at router (D:\Project\Mt-downloader-test-master\node_modules\express\lib\router\index.js:46:12)
请从昨天开始帮助我,我正在寻找一些有用的例子,但我找不到它。
下面是我使用的代码并得到了错误
router.get('/downloadFile', function(req, res, next) {
var createDownload = require('mt-downloader').createDownload
var url = 'https://upload.wikimedia.org/wikipedia/commons/4/47/Gadget_the_pug_expressive_eyes.jpg';
var path = '/Gadget_the_pug_expressive_eyes.jpg';
var downloader = createDownload({path, url});
downloader.start() // returns an observable
});
答案 0 :(得分:-1)
var createDownload = require('mt-downloader');
var url = 'https://upload.wikimedia.org/wikipedia/commons/4/47/Gadget_the_pug_expressive_eyes.jpg';
var path = '/Gadget_the_pug_expressive_eyes.jpg';
var dl=new createDownload();
var downloader = dl.download(url,path);
downloader.start();