本文整理汇总了TypeScript中scp2.Client类的典型用法代码示例。如果您正苦于以下问题:TypeScript Client类的具体用法?TypeScript Client怎么用?TypeScript Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: reject
return new Promise<string>((resolve, reject) => {
let remote = this.getRemotePath(fileName);
// Client upload also creates the folder but creates it using local mode
// in windows it might mean we won't have permissons to save the fileName
// So I create the folder manually here to solve that issue.
// Mode we set can be configured from the config file
this.client.mkdir(upath.dirname(remote), { mode: this.config.pathMode }, err => {
if (err) {
reject({
message: `Could not create ${ upath.dirname(remote) }`,
error: err
});
} else {
// Uplad the file
this.client.upload(fileName, remote, err => {
if (err) {
reject({
message: `Could not upload ${ remote }`,
error: err
});
} else {
resolve(remote);
}
});
}
});
});
示例2: connect
connect(): Promise<string> {
this.client = new Client({
port: this.config.port,
host: this.config.host,
username: this.config.username,
password: this.config.password,
// agentForward: true,
privateKey: this.config.privateKey ? readFileSync(this.config.privateKey).toString() : undefined,
// debug: true
});
// Triggers the initial connection
this.client.sftp((err, sftp) => {
if (err) {
console.log("There was a problem with connection");
}
});
return new Promise<string>((resolve, reject) => {
this.client.on("ready", () => {
resolve("connected");
});
});
}
示例3: resolve
return new Promise<string>((resolve, reject) => {
this.client.on("ready", () => {
resolve("connected");
});
});