当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript scp2.Client类代码示例

本文整理汇总了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);
                        }
                    });
                }
            });
        });
开发者ID:serkanyersen,项目名称:sync,代码行数:28,代码来源:Uploader.ts

示例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");
            });
        });
    }
开发者ID:serkanyersen,项目名称:sync,代码行数:24,代码来源:Uploader.ts

示例3: resolve

 return new Promise<string>((resolve, reject) => {
     this.client.on("ready", () => {
         resolve("connected");
     });
 });
开发者ID:serkanyersen,项目名称:sync,代码行数:5,代码来源:Uploader.ts


注:本文中的scp2.Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。