mscdex / node-ftp

An FTP client module for node.js
MIT License
1.13k stars 244 forks source link

mkdir if directory not exists? #128

Closed kenichi-shibata closed 9 years ago

kenichi-shibata commented 9 years ago

How do you Implement mkdir if directory does not exists? I tried using fs like this

c.on('ready', function() { if (!fs.existsSync(REMOTE_DIRECTORY)){ fs.mkdir(REMOTE_DIRECTORY);} c.put(LOCAL_FILE,REMOTE_DIRECTORY+REMOTE_FILE, function(err) { if (err) throw err; console.log('successfully uploaded file'); c.end(); }); });

probably i cannot do it like this because it is already connected to the ftp Can you make a function that mkdir if not exists? Please :)

Thanks Brian!

mscdex commented 9 years ago

There's already a mkdir() command, provided the server supports it.

kenichi-shibata commented 9 years ago

Yes but how do you implement mkdir() if the dir does not exists?

mscdex commented 9 years ago

I'm afraid I don't understand what the problem is. Are you asking about recursively making a directory on the remote side, like mkdir -p does, or something else?

kenichi-shibata commented 9 years ago

Yes something like mkdir -p but it should not make a directory if it already exists and should log that the directory exists.

kenichi-shibata commented 9 years ago

This is fixed by #80 Thanks Brian!