VFS.ImportFile and VFS.ExportFile
This article presumes the use of features only available in the Ultimate edition of Syncplify Server!, such as at-rest encryption for the virtual file systems (VFS).
As you surely already know, when you use an encrypted VFS all files that any user uploads into such VFS will be encrypted at-rest (on your server’s hard drive).
But what if you need to copy/move those files – as they are uploaded – out of the VFS for further processing? Obviously, if you use the FileCopy/FileMoveCopyFile/MoveFile functions each file will be copied/moved “as is”, in its encrypted form, and other software products won’t be able to read and process it.
Therefore a method to export files from an encrypted VFS to a different and unencrypted location was needed. To do so, you can use the new function ExportFile which is part of the VFS object namespace. When using functions in this namespace we recommend to always verify that VFS is not nil, as this object is not always defined in every execution context. See the script below for example:
{
var vfs = Session.GetCurrentVFS();
if (vfs != null) {
vfs.ExportFile(Session.GetAbsPath(), "/some/directory");
}
}
By the same token the VFS namespace also provides an ImportFile method to import a plain/unencrypted file from your system's file system into an at-rest encrypted VFS managed by Syncplify Server!