Skip to content

Client constructors and connection fields

Each constructor returns a fresh client object with default options already applied. Set the connection fields directly on the returned object and then call Connect().

IMPORTANT

Remote client objects (SftpClient, FtpsClient, S3Client, AzureClient, GCSClient) are available as of Syncplify Server! v7.0.16. Users running an older version do not have access to these features.


SFTP: new SftpClient()

ts
var cli = new SftpClient();
cli.Host         = "sftp.example.com:22";   // "hostname:port" (default port 22)
cli.User         = "alice";
cli.Pass         = GetSecret("sftp-pass");  // password (used unless KeyFile is set)
cli.KeyFile      = "/keys/id_rsa";          // path to PEM or PuTTY .ppk key file
cli.KeyFilePass  = GetSecret("key-pass");   // passphrase for an encrypted key file
cli.HostID       = "my-sftp-server";        // optional label used in log messages

// Host key verification (set exactly one of the three):
cli.HostKeyMD5    = "aa:bb:cc:...";         // MD5 fingerprint (32 hex chars, colons optional)
cli.HostKeySHA1   = "SHA1:base64...";
cli.HostKeySHA256 = "SHA256:base64...";     // recommended (matches ssh-keygen -E sha256)

IMPORTANT

Host key verification is mandatory. At least one of HostKeyMD5, HostKeySHA1, or HostKeySHA256 must be set before calling Connect(). Connections with no known host fingerprint are rejected (insecure mode is not supported).

When KeyFile is set, key-based authentication is attempted. If the key is passphrase-protected, KeyFilePass is used to decrypt it. If KeyFile is not set (or key auth fails), password authentication is used with Pass.


FTP / FTPS: new FtpsClient()

ts
var cli = new FtpsClient();
cli.Host         = "ftp.example.com:21";
cli.User         = "alice";
cli.Pass         = GetSecret("ftp-pass");
cli.TLSMode      = TLS_MODE_EXPLICIT;  // TLS_MODE_NONE | TLS_MODE_EXPLICIT | TLS_MODE_IMPLICIT
cli.TLSInsecure  = false;              // set true only for self-signed certs in controlled environments

See the TLS mode constants table for all values.

WARNING

Only set TLSInsecure = true in controlled internal environments with self-signed certificates. Never use it when connecting to third-party servers.

`SetMode(mode): FTP transfer type

ts
function SetMode(mode: string): bool;

Switches the active FTP transfer type. Must be called after Connect(). Returns true on success.

ConstantValueDescription
FTP_MODE_I"I"Binary / image mod; used for all file transfers (default)
FTP_MODE_A"A"ASCII mode; line-ending translation; use only for plain text

NOTE

Binary mode (FTP_MODE_I) is the default after Connect(). You only need to call SetMode when you explicitly require ASCII mode.

ts
var cli = new FtpsClient();
cli.Host    = "ftp.example.com:21";
cli.User    = "alice";
cli.Pass    = GetSecret("ftp-pass");
cli.TLSMode = TLS_MODE_EXPLICIT;
if (cli.Connect()) {
  cli.SetMode(FTP_MODE_A);  // switch to ASCII for text file transfer
  cli.Upload("/local/reports/*.txt", "/remote/reports");
  cli.Close();
}

Amazon S3 / S3-compatible: new S3Client()

ts
var cli = new S3Client();
cli.Region        = "us-east-1";
cli.AccessKey     = GetSecret("s3-access-key");
cli.SecretKey     = GetSecret("s3-secret-key");
cli.Bucket        = "my-bucket";
cli.Endpoint      = "";      // optional, override for MinIO, Wasabi, Backblaze, etc.
cli.UsePathStyle  = false;   // set true for most S3-compatible services with a custom Endpoint

When both AccessKey and SecretKey are empty, the default AWS credential chain is used: environment variables, ~/.aws/credentials, EC2 instance role, and so on.

For S3-compatible services (MinIO, Wasabi, Backblaze B2, etc.) set Endpoint to the service URL and UsePathStyle to true:

ts
cli.Endpoint     = "https://s3.us-west-000.backblazeb2.com";
cli.UsePathStyle = true;

NOTE

S3 (and compatible) storage has no true directory hierarchy. Directories are emulated via object key prefixes. RenDir and Rename require a copy-then-delete cycle (there is no atomic server-side rename).


Azure Blob Storage: new AzureClient()

ts
var cli = new AzureClient();
cli.AccountName  = "mystorageaccount";
cli.AccountKey   = GetSecret("azure-account-key");  // base64-encoded SharedKey credential
cli.Container    = "my-container";
cli.ServiceURL   = "";   // optional, overrides https://<AccountName>.blob.core.windows.net

When ServiceURL is empty the client connects to the default Azure endpoint. Set it to point at an Azurite local emulator or a sovereign cloud endpoint.

NOTE

Like S3, Azure Blob Storage uses virtual prefix-based directories. RenDir and Rename require a copy-then-delete cycle.


Google Cloud Storage: new GCSClient()

ts
var cli = new GCSClient();
cli.Bucket           = "my-gcs-bucket";
cli.CredentialsFile  = "/keys/service-account.json";  // optional

When CredentialsFile is empty, the default application credentials are used: GOOGLE_APPLICATION_CREDENTIALS environment variable, GCE metadata server, or the gcloud CLI defaults.

NOTE

GCS also uses virtual prefix-based directories. RenDir and Rename require a copy-then-delete cycle.