Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs download image from url

var fs = require('fs'),
    request = require('request');

var download = function(uri, filename, callback){
  request.head(uri, function(err, res, body){
    console.log('content-type:', res.headers['content-type']);
    console.log('content-length:', res.headers['content-length']);

    request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
  });
};

download('https://www.google.com/images/srpr/logo3w.png', 'google.png', function(){
  console.log('done');
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: vue on click router push not working 
Javascript :: change page title js 
Javascript :: how to send header in axios 
Javascript :: string to ascii code js 
Javascript :: check row empty array javascript 
Javascript :: get ip address js 
Javascript :: How to get tailwindcss intellisense to work with react files 
Javascript :: mongoose limit 
Javascript :: tofixed currency in js 
Javascript :: javascript onclick to another page div 
Javascript :: change property name of object in array javascript 
Javascript :: alert with sound javascript 
Javascript :: update style with javascript react components 
Javascript :: input to state 
Javascript :: video in react native stack overflow 
Javascript :: javascript e.key 
Javascript :: javascript format rupiah 
Javascript :: how can we update time in react js 
Javascript :: svelte ondestroy 
Javascript :: hello word in js 
Javascript :: how to submit form using ajax 
Javascript :: latitude and longitude distance calculate in node js 
Javascript :: nestjs version 
Javascript :: nodejs fetch 
Javascript :: react save to local storage 
Javascript :: redux template create react app 
Javascript :: react parameter value from query string 
Javascript :: kb to mb js 
Javascript :: electron open new window 
Javascript :: js propagation stop 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =