Skip to content

ImportFile()

ts
function ImportFile(localFilePath, targetVfsFilePath: string) respBase;

This method of a VFS object imports a file from the local file-system (from your operating system) into the VFS.

IMPORTANT

If the VFS is encrypted at-rest, this function also automatically takes care of encrypting the file during the import phase.

Parameters (function arguments)

ParameterTypeExplanation
localFilePathstringThe fully qualified path of the local file you wish to import into your VFS
targetVfsFilePathstringThe fully qualified path, relative to the VFS root, you wish the file to have in the VFS after import

Example

Let's say, for example, you have the following file in a local disk drive attached to the machine or VM where Syncplify Server! is installed: C:\Data\Budget.xlsx

And let's assume you want to import it into your current VFS (whatever that might be at runtime during a connected client session) in the following position and with the following name relative to the VFS' root: /forecast/budget2025.xlsx

This would be a barebone start for a script to do so:

ts
var vfs = GetCurrentVFS();
if (vfs != null) {
    // notice the \\ to escape the back-slash (if any are present)
    var resp = vfs.ImportFile("C:\\Data\\Budget.xlsx", "/forecast/budget2025.xlsx"); 
    if (resp.Ok()) {
        Log("File successfully imported");
    } else {
        Log("Error importing file: " + resp.ErrorMsg());
    }
} else {
    Log("VFS was null");
}

IMPORTANT

The localFilePath parameter is system-dependent: on Windows it will be a Windows-style path, and on Linux it will be a POSIX path. The targetVfsFilePath is always POSIX regardless of the operating system you run Syncplify Server! on.