javascript - Download file with node-downloader-helper

one text

When I try to download a file and give it a unique name using node-downloader-helper I get the following error:

Error: ENOENT: no such file or directory, open 'C:\Users\ofek.bh\Desktop\Zoon2Drive\zoom-oauth-sample-app\video\TA - QA Apr 2020 - (Wed Jul 15 2020 15:02:08 GMT+0300 (?�???�?? ?�?�?????? (?�?�??))).mp4'
Emitted 'error' event on b instance at:
    at WriteStream.<anonymous> (C:\Users\ofek.bh\Desktop\Zoon2Drive\zoom-oauth-sample-app\node_modules\node-downloader-helper\dist\index.js:1:9035)
    at WriteStream.emit (events.js:326:22)
    at internal/fs/streams.js:375:14
    at FSReqCallback.oncomplete (fs.js:164:23) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\Users\\ofek.bh\\Desktop\\Zoon2Drive\\zoom-oauth-sample-app\\video\\TA - QA Apr 2020 - (Wed Jul 15 2020 15:02:08 GMT+0300 (?�???�?? ?�?�?????? 
(?�?�??))).mp4'

This is my code, The error occurs when I add a value to fileName. When fileName is empty, everything works fine.

const { DownloaderHelper } = require('node-downloader-helper');

function downloaderHelper (url, file_Name) {
    var filePath = `./video`
    var options = {
        method: 'GET', // Request Method Verb
        headers: {},  // Custom HTTP Header ex: Authorization, User-Agent
        fileName: `${file_Name}.mp4`,// Custom filename when saved
        retry: false, // { maxRetries: number, delay: number in ms } or false to disable (default)
        forceResume: false, // If the server does not return the "accept-ranges" header, can be force if it does support it
        removeOnStop: true, // remove the file when is stopped (default:true)
        removeOnFail: true, // remove the file when fail (default:true)
        // override: true,
        httpRequestOptions: {}, // Override the http request options  
        httpsRequestOptions: {}, // Override the https request options, ex: to add SSL Certs
    }

    const dl = new DownloaderHelper(url, __dirname+'/video/', options);
    
    dl.on('end', () => console.log('Download Completed'))
    dl.start();
}


exports.downloaderHelper = downloaderHelper;

My ultimate goal is to download a video file via URL, save the file in a dedicated folder and rename it.

Thanks!!

Source