ssh2-sftp-client
ssh2-sftp-client copied to clipboard
support chown
Please support chown function.
I created it:
/**
* @async
*
* Change the owner of a remote file on the SFTP repository
*
* @param {string} remotePath - path to the remote target object.
* @param {number | string} uid - the owner id to set
* @param {number | string} gid - the group id to set
* @param {boolean} addListeners - (Optional) if true, add listeners. Default true.
*
* @return {Promise<String>}
*/
chown(rPath, uid, gid, addListeners = true) {
let listeners
return new Promise((resolve, reject) => {
if (addListeners) {
listeners = addTempListeners(this, 'chown', reject)
}
if (haveConnection(this, 'chown', reject)) {
this.sftp.chown(rPath, uid, gid, (err) => {
if (err) {
reject(this.fmtError(`${err.message} ${rPath}`, '_chown', err.code))
}
resolve('Successfully change file owner')
})
}
}).finally(() => {
if (addListeners) {
removeTempListeners(this, listeners, 'chown')
}
})
}
Will try to add this for the next release.
At this point, there is no timeline as to when this will be.