MoveToVFS()
ts
MoveToVFS(localFile: string, targetVfs: VirtualFileSystem, targetVfsFilePath: string): respBase;Moves a file, identified by its root-based POSIX path inside the caller VFS, to a different VFS (object of type VirtualFileSystem) in the specified target path of the receiving VFS.
Parameters
| Parameter | Type | Explanation |
|---|---|---|
localFile | string | The fully qualified, root-based POSIX path (in the caller VFS) of the file you wish to move |
targetVfs | VirtualFileSystem | The VFS you wish to move the file to; this must be different from the caller-VFS (origin) |
targetVfsFilePath | string | The fully qualified path, relative to the recipient-VFS root, you wish the file to have in the VFS after import |
Example
ts
// Make sure we have a caller (origin) VFS to move the file from
var originVfs = GetCurrentVFS();
if (originVfs == null) {
Exit(1);
}
// Then let's see if we can create the destination VFS pointing to S3
var recipientVfs = new VirtualFS(
VfsTypeS3,
"s3://myS3bucket",
"{\"accessKey\":\"AKIA...\",\"secretKey\":\"...\"}"
);
if (recipientVfs != null) {
var resp = originVfs.MoveToVFS("/data/file.txt", recipientVfs, "/backup/file.txt");
if (resp.Ok()) {
Log("File moved to S3");
} else {
Log("Error: " + resp.ErrorMsg());
}
}WARNING
As expected with any "move" operation, once the file is moved it will no longer exist in the origin VFS, and it will only be present in the recipient VFS.
