nodejs createwritestream file imagem quebrada
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)
})
}
Restu Wahyu Saputra