“NodeJS CreateWriteStream File Image rusak” Kode Jawaban

NodeJS CreateWriteStream File Image rusak

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

NodeJS CreateWriteStream File Image rusak

export const streamFile = async (imageUrl: string, imageName: string) => {
	const filename: string = `${process.env.IMG_DIR}/${imageName}`
	const writeFile: fs.WriteStream = fs.createWriteStream(filename)

	const res: request.Request = await request(imageUrl)
	res.pipe(writeFile)
	res.on('data', (chunk: Buffer) => writeFile.write(chunk))
	res.on('complete', () => {
		writeFile.end()
		console.info('Streaming file success')
	})
	res.on('error', () => console.error('Streaming file error'))
}
Restu Wahyu Saputra

NodeJS CreateWriteStream File Image rusak

const { DownloaderHelper } = require('node-downloader-helper');
const dl = new DownloaderHelper('https://proof.ovh.net/files/1Gb.dat', __dirname);

dl.on('end', () => console.log('Download Completed'))
dl.start();
Restu Wahyu Saputra

Jawaban yang mirip dengan “NodeJS CreateWriteStream File Image rusak”

Pertanyaan yang mirip dengan “NodeJS CreateWriteStream File Image rusak”

Lebih banyak jawaban terkait untuk “NodeJS CreateWriteStream File Image rusak” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya