Fs 쓰트림

코드 예제

1
0

writeFile 를 사용하여 스트림 및 라이브러리에서 문자열

const stream = require('stream')
const fs = require('fs')

const html = "<h1> Hello Wordl </h1>

// read file from string and write file
const stream = new Stream()
stream.pipe = function (dest) {
  dest.write(html)
  return dest
}
stream.pipe(createWriteStream(resolve(process.cwd(), 'index.html'), 'utf8'))

// read file from directory and write file
fs.createReadStream('testing.html')
 .pipe(createWriteStream(resolve(process.cwd(), 'index.html'), 'utf8'))
1
0

fs 쓰 스트림에 추가

fs.createWriteStream("append.txt", {flags:'a'});
0
0

및 라이브러리 스트림 작성 파일

const readFile: InstanceType<typeof stream.Readable> = new stream.Readable({
  read() {
    return true
  }
})
readFile
  .pipe(fs.createWriteStream(`${process.env.IMG_DIR}/${Date.now().toString()}-${file.originalname}`))
  .on('finish', Promise.resolve)
  .on('error', Promise.reject)

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................