Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

download-to-file.js 583B

123456789101112131415161718
  1. var fs = require('fs'),
  2. needle = require('./..'),
  3. path = require('path');
  4. var url = process.argv[2] || 'https://upload.wikimedia.org/wikipedia/commons/a/af/Tux.png';
  5. var file = path.basename(url);
  6. console.log('Downloading ' + file);
  7. needle.get(url, { output: file, follow: 3 }, function(err, resp, data){
  8. console.log('File saved: ' + process.cwd() + '/' + file);
  9. var size = fs.statSync(file).size;
  10. if (size == resp.bytes)
  11. console.log(resp.bytes + ' bytes written to file.');
  12. else
  13. throw new Error('File size mismatch: ' + size + ' != ' + resp.bytes);
  14. });