node.js - No such file or directory when piping from request in Node -


i need request .zip file url pass contents admzip

when attempting pipe output of request library:

const zipfilepath = path.join(batchpath, this.zipfile.filename); const out = fs.createwritestream(zipfilepath);  const req = request.get(this.zipfile.url); req.pipe(out); req.on('end', function() {   console.log("i should here, i'm not"); }); 

i receive:

error: enoent: no such file or directory, open 'c:\users\brandon\work\keystone4-projects\html-email\batch-content\5996588a3bc30010502bfa9e\test.zip'

what doing wrong?

edit:

i added:

if (!fs.existssync(batchpath)) {   fs.mkdirsync(batchpath); } 

before attempting pipe output , function completed successfully.

typically when receive error when writing file, means path leading file being written not exist.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

php - Cannot override Laravel Spark authentication with own implementation -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -