Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nodejs createwriteStream file image broken

function d() {
var data = [
    {
        img: "http://wow.zamimg.com/images/hearthstone/cards/enus/original/OG_134.png",
        cardId: "yogg"
    },
    {
        img: "http://wow.zamimg.com/images/hearthstone/cards/enus/original/HERO_07.png",
        cardId: "nzoth"
    }
];
var async = require('async')
async.each(data, (card, next) => {
    if("img" in card) {
        var img = require('fs').createWriteStream(card.cardId + ".png");
          require("http").get(card.img, (res) => {
              res.pipe(img).on('end', next)
          });
    }
}
, () => {
  console.log(done)
})
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #nodejs #createwriteStream #file #image #broken
ADD COMMENT
Topic
Name
5+8 =