本文整理汇总了TypeScript中ftp.connect函数的典型用法代码示例。如果您正苦于以下问题:TypeScript connect函数的具体用法?TypeScript connect怎么用?TypeScript connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connect函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: testConnection
public testConnection(host: string, port: number, username: string, password: string): void {
var client = new ftp();
client.on('ready', () => {
client.list((err, list) => {
if (err) console.error(err);
console.dir(list);
client.end();
alert("Connection Successful");
});
});
client.on('error', (err) => {
console.error(err);
});
client.connect({
host: host,
port: port,
user: username,
password: password,
secure: true,
secureOptions: { rejectUnauthorized: false }
});
}
开发者ID:joedono,项目名称:No-CI,代码行数:26,代码来源:ftp-upload.service.ts
示例2:
}).on('error', (err) => {
if (options.attempts > limit) {
deferred.reject(err);
}
options.attempts++;
ftp.connect(options);
});
开发者ID:chrisk-symphony,项目名称:sy-trans,代码行数:7,代码来源:FTP.ts
示例3: _createReadableStream
/**
* @hidden and @ignore
*/
public _createReadableStream(option: FtpReadOption): Readable {
const connector = new Connector();
if (option.path === undefined) {
const reader = new Readable();
process.nextTick(() => {
reader.emit("error", new Error(SourceError[421]), option);
reader.destroy();
});
return reader;
} else {
const client = new Client();
client.on("ready", () => {
client.get(option.path as string, (e, stream) => {
if (e) {
connector.emit("error", e, option);
connector.destroy();
} else {
stream.pipe(connector);
stream.on("close", () => {
client.end();
// self.emit('end', self);
});
}
});
});
// connect to localhost:21 as anonymous
// client.on("error", (error) => {
// err = error;
// });
client.connect(option);
}
return connector as Readable;
}
开发者ID:node-dmr,项目名称:dmr-source,代码行数:36,代码来源:source-ftp.ts
示例4: writeFile
writeFile (options: any, file: any) {
options.user = options.username ? options.username : options.user;
const ftp = new nodeFTP(),
deferred = this.deferred(),
limit = 20;
options.attempts = 0;
ftp.on('ready', () => {
const writeStream = new Writable(file.path);
const readStream = new Readable();
readStream.push(file.content);
readStream.push(null);
ftp.put(readStream, file.path, (err) => {
if (err) {
deferred.reject(err);
}
ftp.end();
deferred.resolve({});
});
}).on('error', (err) => {
if (options.attempts > limit) {
deferred.reject(err);
}
options.attempts++;
ftp.connect(options);
});
ftp.connect(options);
return deferred.promise;
}
开发者ID:chrisk-symphony,项目名称:sy-trans,代码行数:32,代码来源:FTP.ts
示例5: readFile
readFile(options: any, file: any) {
options.user = options.username ? options.username : options.user;
const deferred = this.deferred();
const ftp = new nodeFTP();
ftp.on('ready', () => {
ftp.get(file.path, (err, stream) => {
if (err) {
deferred.reject(err);
}
let content = "";
stream.on('data', (chunk) => {
content += chunk;
}).on('end', () => {
ftp.end();
deferred.resolve(content);
}).on('error', (err) => {
ftp.end();
deferred.reject(err);
});
})
});
ftp.connect(options);
return deferred.promise;
}
开发者ID:chrisk-symphony,项目名称:sy-trans,代码行数:28,代码来源:FTP.ts
示例6: moveFile
moveFile (options: any, fromPath: string, toPath: string) {
options.user = options.username ? options.username : options.user;
const ftp = new nodeFTP(),
deferred = this.deferred(),
limit = 20;
options.attempts = 0;
ftp.on('ready', () => {
ftp.rename(fromPath, toPath, (err, data) => {
if (err) {
deferred.reject(err);
}
ftp.end();
deferred.resolve({});
});
}).on('error', (err) => {
if (options.attempts > limit) {
deferred.reject(err);
}
options.attempts++;
ftp.connect(options);
});
ftp.connect(options);
return deferred.promise;
}
开发者ID:chrisk-symphony,项目名称:sy-trans,代码行数:28,代码来源:FTP.ts
示例7: Promise
return new Promise((resolve) => {
const ftp = new FtpClient();
ftp.on("error", (err) => {
ftp.end();
console.log(err);
resolve(localStat);
});
ftp.on("ready", () => {
ftp.list(jdfPath, (err, list) => {
if (err) {
ftp.end();
console.log(err);
resolve(localStat);
} else {
const index = indexOfJdf(list);
if (index >= 0) {
const remoteStat = list[indexOfJdf(list)];
if (localStat
&& (localStat.size === parseInt(remoteStat.size)
&& localStat.mtime.getTime() == remoteStat.date.getTime())) {
ftp.end();
resolve(localStat);
} else {
ftp.get(remoteJdfPath, (err, stream) => {
if (err) {
ftp.end();
console.log(err);
resolve(localStat);
} else {
stream.once("close", () => {
ftp.end();
});
stream.pipe(fs.createWriteStream(localJdfPath).once("close", () => {
fs.utimesSync(localJdfPath, new Date, remoteStat.date);
resolve(getFileStat(localJdfPath));
}));
}
});
}
} else {
ftp.end();
resolve(localStat);
}
}
});
});
ftp.connect({
// secure: true,
// secureOptions: {
// rejectUnauthorized: false
// },
// user: "",
// password: "",
host: cisjr
});
});
开发者ID:graycrow,项目名称:node-cisjr,代码行数:59,代码来源:index.ts
示例8: upload
public upload(rootPath: string, files: CommitFile[], ftpConfig: FtpConfig, logger: EventEmitter<string>) {
rootPath = rootPath.replace(/\\/gi, "/") + "/";
var ftpRootFolder = ftpConfig.IsStaging ? StagingFolder : ProductionFolder;
var client = new ftp();
logger.emit('Repo Selected: ' + rootPath);
logger.emit('Files Queued: ' + files.length);
client.on('ready', () => {
logger.emit('Connected to FTP Server');
files.forEach((commitFile) => {
if(commitFile.Status === 'A' || commitFile.Status === 'M') {
logger.emit('Uploading: ' + rootPath + commitFile.FileName);
logger.emit('To: ' + ftpRootFolder + commitFile.FileName);
client.put(rootPath + commitFile.FileName, ftpRootFolder + commitFile.FileName, (err) => {
if(err) {
logger.emit('ERROR: ' + err);
} else {
logger.emit('Upload successful: ' + commitFile.FileName);
}
});
}
});
client.end();
});
client.on('error', (err) => {
logger.emit('ERROR: ' + err);
});
client.connect({
host: ftpConfig.Host,
port: ftpConfig.Port,
user: ftpConfig.Username,
password: ftpConfig.Password,
secure: true,
secureOptions: { rejectUnauthorized: false }
});
}
开发者ID:joedono,项目名称:No-CI,代码行数:42,代码来源:ftp-upload.service.ts
示例9: readDir
readDir(options: any, path: string) {
options.user = options.username ? options.username : options.user;
const deferred = this.deferred();
const me = this,
ftp = new nodeFTP();
ftp.on('ready', () => {
ftp.list(path, (err, list) => {
if (err) {
// throw err;
deferred.reject(err);
}
deferred.resolve(list);
});
});
ftp.on('error', (err) => {
deferred.reject(err);
});
ftp.connect(options);
return deferred.promise;
}
开发者ID:chrisk-symphony,项目名称:sy-trans,代码行数:24,代码来源:FTP.ts
示例10: function
}
c.on('ready', function () {
tl.debug('connected to ftp host:' + serverEndpointUrl.host);
if (clean) {
tl.debug('cleaning remote: ' + remotePath);
remoteExists(remotePath, function(exists){
if(exists){
c.rmdir(remotePath, true, function (err) {
if (err) {
c.destroy();
failTask('Unable to clean remote folder: ' + remotePath + ' error: ' + err);
}
uploadFiles();
});
} else {
uploadFiles();
}
});
} else {
tl.debug('skipping clean: ' + remotePath);
uploadFiles();
}
});
var secure = serverEndpointUrl.protocol.toLowerCase() == 'ftps:' ? true : false;
tl.debug('secure ftp=' + secure);
c.connect({ 'host': serverEndpointUrl.host, 'user': username, 'password': password, 'secure': secure });
开发者ID:ColinDabritz,项目名称:vsts-tasks,代码行数:30,代码来源:ftpuploadtask.ts
注:本文中的ftp.connect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论