React Native
React Native
SFTP SymLink - Create Symbolic Link on Server
See more SFTP Examples
Demonstrates how to create a symbolic link on the SFTP server.Chilkat React Native Downloads
import { SFtp } from '@chilkat/react-native'
async function chilkatExample() {
let success = false;
// This example requires 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;
}
// Create a symbolic link on the server.
// We'll create a link in our HOME directory named "sshd_config"
// which points to the file /etc/ssh/sshd_config.
success = true;
try {
await sftp.symLinkAsync('/etc/ssh/sshd_config', 'sshd_config');
} catch {
success = false;
}
if (!success) {
console.log(sftp.lastErrorText);
return;
}
console.log('Successfully created symbolic link.');
}