A
A
AndreyKawilov2021-09-02 19:00:52
Node.js
AndreyKawilov, 2021-09-02 19:00:52

Node js outputs strange filenames, how to fix?

When unpacking the archive with the names of files and folders, something strange happens (the language must be Russian)

const decompress = require('decompress')
const http = require('https')
const fs = require('fs')

const date = Date.now()
const file = fs.createWriteStream(`temp/file-${date}.zip`)
console.log(`temp/file-${date}.zip`)
const URL = "https://cloud.mfua.ru/iblock/f9a/f9ababc45da052df3e5b046da3d78bcf/%D0%A0%D0%B0%D1%81%D0%BF%D0%B8%D1%81%D0%B0%D0%BD%D0%B8%D0%B5+%D0%B7%D0%B0%D0%BD%D1%8F%D1%82%D0%B8%D0%B9+%D0%9C%D0%98%D0%A2%D0%A3-%D0%9C%D0%90%D0%A1%D0%98.zip"

const request = http.get(URL, function (response) {
  console.log(response.path)
  response.pipe(file)
  setTimeout(function () {
    UnZip()
  }, 3000);
})

async function UnZip() {
  decompress(`temp/file-${date}.zip`, 'temp', {
    map: file => {
      console.log(file.path)
      file.path = `file-${file.path}`;
      return file;
    }
  }).then(files => {
    console.log('done!');
  });
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question