“NodeJS Createwritestream -Datei Bild gebrochen” Code-Antworten

NodeJS Createwritestream -Datei Bild gebrochen

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 -Datei Bild gebrochen

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 -Datei Bild gebrochen

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

Ähnliche Antworten wie “NodeJS Createwritestream -Datei Bild gebrochen”

Fragen ähnlich wie “NodeJS Createwritestream -Datei Bild gebrochen”

Weitere verwandte Antworten zu “NodeJS Createwritestream -Datei Bild gebrochen” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen