Skip to content

Download a file using ada? #572

Closed Answered by lemire
flaviu22 asked this question in Q&A
Dec 4, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

The ada library is part of the Node.js runtime. If you download a file using the Node.js runtime, it will use ada:

const request = require('request');
const fs = require('fs');

const downloadFile = (url, filePath) => {
  const file = fs.createWriteStream(filePath);
  request(url).pipe(file).on('close', () => {
    console.log('File downloaded successfully.');
  }).on('error', (err) => {
    fs.unlink(filePath);
    console.error(`Error while downloading file: ${err.message}`);
  });
};

downloadFile('https://www.google.com', 'index.html');

If ada is an alternative for curl,

The ada library is an alternative to the curl component that parses URLs.

If you found some documentation that im…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@flaviu22
Comment options

Answer selected by flaviu22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants