當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。