React Native
React Native
SFTP ReadLink - Get the Target of a Symbolic Link on the Server
See more SFTP Examples
Demonstrates how to retrieve the target of a symbolic link on the SFTP server.Note: This example requires Chilkat v9.5.0.71 or greater.
Chilkat React Native Downloads
import { SFtp } from '@chilkat/react-native'
async function chilkatExample() {
let success = false;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const sftp = new SFtp();
// Pass a domain or IP address..
success = true;
try {
await sftp.connectAsync('my-sftp-server.com', 22);
} catch {
success = false;
}
if (success) {
success = true;
try {
await sftp.authenticatePwAsync('mySFtpLogin', 'mySFtpPassword');
} catch {
success = false;
}
}
if (success) {
success = true;
try {
await sftp.initializeSftpAsync();
} catch {
success = false;
}
}
if (!success) {
console.log(sftp.lastErrorText);
return;
}
// In this example, the we already have a symbolic link named "sshd_config"
// in our SSH/SFTP user account's HOME directory. Get the target of this link:
let path: string;
try {
path = await sftp.readLinkAsync('sshd_config');
} catch {
console.log(sftp.lastErrorText);
return;
}
console.log(`symlink target path = ${path}`);
// Output is:
// symlink target path = /etc/ssh/sshd_config
}