node.js - nodejs writen file is empty -



node.js - nodejs writen file is empty -

i have little problem, when seek re-create 1 file tmp dir ftp dir writen file empty. have no error, don't understand i'm doing wrong

var ftppath = "/var/www/ftp/", zippath = "/var/www/tmp/", file = "test"; fs.createreadstream(zippath + file).pipe(fs.createwritestream(ftppath + file));

my test file contain loremipsum sample.

if have solution, take it, line bug in app :(

thank you

first, create sure file /var/www/tmp/test exists, file, , has right permissions user start script with.

second, create sure /var/www/ftp/ has writing permissions.

then next code should work :

var readerstream = fs.createreadstream('/var/www/tmp/test'); var writerstream = fs.createwritestream('/var/www/ftp/test'); readerstream.pipe(writerstream);

edit :

try debugging using snippet :

var data; var readerstream = fs.createreadstream('/var/www/tmp/test'); readerstream.on('data', function(data) { info += data; }); readerstream.on('end', function() { console.log(data); });

node.js streamwriter

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -