Registering a virtual file

Home > Basic examples > Example 03

Explanation

A virtual file is a virtual file that does not exist on the user's local PC. In general, virtual files are used to keep information about already uploaded files. That is, it is used as an indication that the file exists in the server. It is not a file to upload because it is not actually locally present.

To register a virtual file, use the addVirtualFile function or the addVirtualFileList function. Virtual files are registered in the json object format.

var dx = dx5.get(id);
// When registering individually 
dx.addVirtualFile({ vindex: "IDX0001", name: "virtual_file.txt", size: 12345 });
dx.addVirtualFile({ vindex: "IDX0002", name: "virtual_file_locked.txt", size: 45678, lock: true });
dx.addVirtualFile({ vindex: "IDX0003", name: "cosmos.jpg", size: 195779 });

// When registering several at once 
dx.addVirtualFileList([
	{ vindex: "IDX0001", name: "virtual_file.txt", size: 12345 },
	{ vindex: "IDX0002", name: "virtual_file_locked.txt", size: 45678, lock: true },
	{ vindex: "IDX0003", name: "cosmos.jpg", size: 195779 }
]);

Note that the addVirtualFile and addVirtualFileList functions register files asynchronously, so the code following the two functions can be executed first.

Example