Create Folder on SFTP server using ssh2 npm module in NodeJS with permissions

27 views Asked by At

I am using this npm module for my SFTP iplementation.

As I need to create a folder on my SFTP server where I can upload my file. I have read the documentation but nothing is mentioned about this.

How to create a folder on SFTP server with the permission 770 using ssh2 npm module?

I have tried:

sftp.mkdir(directory, 770, function(err) {})
sftp.mkdir(directory, '770', function(err) {})
sftp.mkdir(directory, '0770', function(err) {})
sftp.mkdir(directory, { mode: '0770' }, function(err) {})
sftp.mkdir(directory, { mode: '770' }, function(err) {})

These all create the directory, but do not set the permissions.

I found the sftp.chmod function and this works, but requires another request to the server,

sftp.chmod(directory, '0770', function(err) {})

So I was hoping there was a way to create the directory and set the permission all in one function/method.

0

There are 0 answers