How to use the ssh2.SFTP_STATUS_CODE.NO_SUCH_FILE function in ssh2

To help you get started, we’ve selected a few ssh2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dobbydog / sftp-sync-deploy / lib / sftpSync.ts View on Github external
const files = fs.readdirSync(localPath);
      if (files && files.length) {
        await Promise.all(
          files.map(filename => this.upload(path.posix.join(relativePath, filename), false))
        );
      }
    } else {
      try {
        // const buffer = fs.readFileSync(localPath);
        // const handle = await this.queuifiedSftp.open(remotePath, 'r+');
        // await this.queuifiedSftp.writeData(handle, buffer, 0, buffer.length, 0);
        // await this.queuifiedSftp.close(handle);
        await this.queuifiedSftp.fastPut(localPath, remotePath);
      } catch (err) {
        switch (err.code) {
          case SFTP_STATUS_CODE.NO_SUCH_FILE: {
            throw new Error(`Remote Error: Cannot upload file ${remotePath}`);
          }
          case SFTP_STATUS_CODE.PERMISSION_DENIED: {
            throw new Error(`Remote Error: Cannot upload file. Permission denied ${remotePath}`);
          }
          case SFTP_STATUS_CODE.FAILURE: {
            throw new Error(`Remote Error: Unknown error while uploading file ${remotePath}`);
          }
          default: throw err;
        }
      }
    }

    if (isRootTask) this.close();
  }
github silexlabs / unifile / test / unifile-sftp.js View on Github external
.catch((e) => {
								if(e.code === 'ENOENT')
									sftpStream.status(reqid, SFTP_STATUS_CODE.NO_SUCH_FILE);
								else
									sftpStream.status(reqid, SFTP_STATUS_CODE.FAILURE);
							});
						})
github silexlabs / unifile / test / unifile-sftp.js View on Github external
							.catch((err) => sftpStream.status(reqid, SFTP_STATUS_CODE.NO_SUCH_FILE))
							.then((stats) => sftpStream.attrs(reqid, stats));