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 tofileName
.
WhenfileName
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!!
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
JavaScript is a multi-paradigm language that supports event-driven, functional, and mandatory (including object-oriented and prototype-based) programming types. Originally JavaScript was only used on the client side. JavaScript is now still used as a server-side programming language. To summarize, we can say that JavaScript is the language of the Internet.
https://www.javascript.com/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.