Options (for ALL client objects)¶
Options = {
StopOnTransferError: boolean
DownloadPolicy: TransferPolicy // default: NeverOverwrite (see below)
UploadPolicy: TransferPolicy // default: NeverOverwrite (see below)
OnDownloadGrantTo: string
AdjustTimeOnDownload: boolean
AdjustTimeOnUpload: boolean
DownloadWithTempName: boolean
UploadWithTempName: boolean
DeleteSourceAfterDownload: boolean
DeleteSourceAfterUpload: boolean
VersionedDownload: boolean
VersionedUpload: boolean
VersionsToKeepLocal: integer // default: 3
VersionsToKeepRemote: integer // default: 3
OTFE: boolean
OTFEKey: string
OTFEKeyFromSecret: string
}
TransferPolicy = {
NeverOverwrite: integer = 0
AlwaysOverwrite: integer = 1
OverwriteIfDiffSize: integer = 2
OverwriteIfNewer: integer = 3
}
Every client object, regardless of the file transfer protocol it implements, will have an Options
property like the one described here above.
Here below you can find an explanation of what each one of such options means.
StopOnTransferError
: if true, any upload or download operation will immediately terminate if a file transfer error occurs,
otherwise (if false) Syncplify.me AFT! will try to keep uploading/downloading the remaining queued files; this property defaults to false.
DownloadPolicy
is the policy that the client object will apply to all downloads, and specifically:
NeverOverwrite
: if a file with the same name already exists on the local file system, it will not be downloaded (this is the default value)
AlwaysOverwrite
: all files will always be downloaded, even if it means that local files are going to be overwritten
OverwriteIfDiffSize
: if a local file with the same name exists, the remote file will be downloaded (overwriting the local one) only if the size is different
OverwriteIfNewer
: if a local file with the same name exists, the remote file will be downloaded (overwriting the local one) only if the remote file is more recent (looking at the last modification date)
UploadPolicy
is the policy that the client object will apply to all downloads, and specifically:
NeverOverwrite
: if a file with the same name already exists on the local file system, it will not be uploaded (this is the default value)
AlwaysOverwrite
: all files will always be uploaded, even if it means that local files are going to be overwritten
OverwriteIfDiffSize
: if a local file with the same name exists, the remote file will be uploaded (overwriting the local one) only if the size is different
OverwriteIfNewer
: if a local file with the same name exists, the remote file will be uploaded (overwriting the local one) only if the remote file is more recent (looking at the last modification date)
OnDownloadGrantTo
: when AFT! is running as a system service, all downloaded files will be owned by “System” (on Windows) or “root” (on Linux/POSIX systems).
If you specify this option, then AFT! will grant access (in Windows) or ownership (in Linux/POSIX) to all downloaded files to the username specified by this option.
AdjustTimeOnDownload
: if true, the last modification time of each downloaded file will be adjusted to match the last modification time of
the original file on the remote file server; this property defaults to true.
AdjustTimeOnUpload
: if true, the last modification time of each uploaded file will be adjusted to match the last modification time of the
original file on the local file system; this property defaults to true.
DownloadWithTempName
: if true, all downloads will be operated using a temporary file, and only after a successful and complete download
the temporary file will be renamed to the actual original name of the downloaded file. This property defaults to false.
UploadWithTempName
: if true, all uploads will be operated using a temporary file, and only after a successful and complete upload the
temporary file will be renamed to the actual original name of the uploaded file. This property defaults to false.
DeleteSourceAfterDownload
: if true, after a file has been successfully downloaded, the original file (on the remote file server) is deleted,
effectively turning the download into a “file move” operation from the remote to the local side. This property defaults to false.
DeleteSourceAfterUpload
: if true, after a file has been successfully uploaded, the original file (on the local file-system) is deleted,
effectively turning the upload into a “file move” operation from the local to the remote side. This property defaults to false.
VersionedDownload
: if true, and if the other options require the destination local file to be overwritten by the one that’s being downloaded,
this option instructs AFT! to automatically keep the old version of the same file in a “.ver” sub-directory of the current local directory. This property defaults to false.
VersionedUpload
: if true, and if the other options require the destination remote file to be overwritten by the one that’s being uploaded,
this option instructs AFT! to automatically keep the old version of the same file in a “.ver” sub-directory of the current remote directory. This property defaults to false.
VersionsToKeepLocal
: used in conjunction with VersionedDownload, this property indicates the number of older versions of each file that
AFT! will keep in the local “.ver” sub-directory. Defaults to 3.
VersionsToKeepRemote
: used in conjunction with VersionedUpload, this property indicates the number of older versions of each file that
AFT! will keep in the remote “.ver” sub-directory. Defaults to 3.
OTFE
: short for On-The-Fly-Encryption, this property indicated whether AFT! should encrypt files as they are uploaded to a remote file server,
and decrypt them as they are downloaded back to the local storage. Defaults to false.
OTFEKey
: a secret word, password or keyword, from which the encryption key will be derived, when the OTFE property is set to true.
Please do not type your passwords or encryption keys in clear! Use GetSecret instead, or - even better - use the OTFEKeyFromSecret property here below.
OTFEKeyFromSecret
: the name of a stored secret (read more about secrets) to be used as seed to derive the encryption key to be used by
the On-The-Fly-Encryption algorithm when the OTFE property is set to true. If both the OTFEKeyFromSecret and OTFEKey properties are specified,
the OTFEKeyFromSecret property prevails.
Example
{
var cli = new SftpClient();
cli.Host = 'your.sftpserver.com:22';
cli.User = 'someusername';
cli.KeyFile = './my_id.rsa';
cli.Options.UploadPolicy = NeverOverwrite;
cli.Options.AdjustTimeOnUpload = false;
cli.Options.StopOnTransferError = true;
if (cli.Connect()) {
// perform your file transfers...
// ...
// ...
cli.Close();
}
cli = null
}