Skip to content

Global constants

SyncJS exposes a set of named constants as global variables. Using constants instead of raw values makes scripts more readable and protects them against future changes to the underlying numeric or string representations.


VFS type constants

Used as the first argument to new VirtualFS(vfsType, target, payload).

ConstantValueDescription
VfsTypeDisk"Disk"Local disk or network path; no payload required
VfsTypeS3"S3"Amazon S3 or S3-compatible object storage
VfsTypeAzure"Azure"Microsoft Azure Blob Storage
VfsTypeGCS"GCP"Google Cloud Storage
VfsTypeSFTP"SFTP"SFTP remote server
VfsTypeR2FS"R2FS"Syncplify R2FS distributed storage
ts
var vfs = new VirtualFS(VfsTypeDisk, "/data/incoming");

Sort field constants

Used as the sortBy argument to VFS ReadDir().

ConstantValueSort key
SortByName"name"Alphabetical by name
SortByNameDirsFirst"namedf"Alphabetical by name, directories listed before files
SortBySize"size"Ascending file size
SortByTime"time"Modification timestamp

Sort direction constants

Used as the sortDir argument to VFS ReadDir().

ConstantValueOrder
SortAsc"asc"Ascending (A to Z, oldest to newest, smallest to largest)
SortDesc"desc"Descending (Z to A, newest to oldest, largest to smallest)
ts
var entries = vfs.ReadDir("/archive", SortByTime, SortDesc);

Seek origin constants

Used as the whence argument to VFS ReadFileAsText(), ReadFileAsBytes(), ReadFileAsHex(), WriteFileAsText(), WriteFileAsBytes(), and WriteFileAsHex().

ConstantValueMeaning
FromStart0offset is measured from the beginning of the file
FromCurrent1offset is measured from the current read/write position
FromEnd2offset is measured from the end of the file
ts
// Append 512 bytes read from the end of a file
var data = vfs.ReadFileAsBytes("/log/app.log", 512, 0, FromEnd);

NOTE

FromCurrent is primarily useful when reading or writing a file in sequential chunks inside a loop. When reading from the beginning with a fixed offset, FromStart is sufficient for most use cases.


Other constant groups

The following constant groups are documented in the sections where they are consumed rather than here, to keep the usage context close to the reference:

GroupWhere to find it
Directory listing filter (LIST_ALL, LIST_FILES, LIST_DIRS)Remote clients: operations reference
Transfer policy (NeverOverwrite, AlwaysOverwrite, etc.)Remote clients: operations reference
On-the-fly encryption (OTFEAlgoAES256GCM, OTFEAlgoOpenPGP)Remote clients: operations reference
TLS mode (TLS_MODE_NONE, TLS_MODE_EXPLICIT, TLS_MODE_IMPLICIT)Remote clients: constructors
FTP transfer mode (FTP_MODE_I, FTP_MODE_A)Remote clients: constructors