IVault Interface |
Namespace: PDTec.IceNet.Core.Database
public interface IVault
The IVault type exposes the following members.
Name | Description | |
---|---|---|
Description |
The vault description. The description can be empty.
| |
DisplayName |
The display name.
| |
Id |
The vault ID. The ID is generated by the platform and
cannot be modified.
| |
Name |
The vault name. The name must be unique and must follow the QName convention.
| |
VaultType |
Gets the vault type.
|
Name | Description | |
---|---|---|
CreateFileContent(Int64) | Obsolete.
Creates a file content.
| |
CreateFileContent(Int64, String) |
Creates a file content.
| |
Destroy |
Deletes the vault. This method fails if the vault still contains file content.
| |
DestroyFileContent |
Destroys a file content.
| |
GetParameters |
Gets the vault parameters.
| |
GetProtocol |
Retrieves the vault protocol interface for accessing the file contents.
| |
SetParameter |
Sets a vault parameter.
| |
UpdateFileContent |
Updates a file content.
|
This example explains how to work with vaults and file content directly. This can be useful to implement a transactional safe Web uploading process that enables to upload large files in parts, where the whole uploading process cannot be encapsulated in a single database transaction for HTTP request memory size and timeout reasons:
This procedure ensures that if the upload process fails at one point, the file object does not appear in the database at all. This avoids broken file objects. Unconnected FileContents can be identified and removed easily by a vault utility.
The following code shows how to create a file in several steps and how the individual transactions can be separated from each other.
byte[] aContent = Encoding.ASCII.GetBytes("1234567890"); IVault pVault = Repository.GetVaultByName("System.Database"); string contentUuid = null; // // First step: create a FileContent record in the database... // string hash = FileUtils.CalculateHash(aContent); Repository.ExecuteTransaction(delegate { contentUuid = pVault.CreateFileContent(aContent.Length, hash).Uuid; }); // // Second step: Use the IVaultProtocol of the vault to upload the content... // IVaultProtocol pProtocol = pVault.GetProtocol(); string correlationId = CreateFileContentPartStart(contentUuid); pProtocol.CreateFileContentPartContinue(contentUuid, correlationId, 0, aContent.Take(5).ToArray()); pProtocol.CreateFileContentPartContinue(contentUuid, correlationId, 1, aContent.Skip(5).ToArray()); pProtocol.CreateFileContentPartComplete(contentUuid, correlationId, 2); // // Final step: Create the File object and connect the FileContent as a new content version... // IFile pFile = null; Repository.ExecuteTransaction(delegate { pFile = Repository.GetObjTypeByName("Core.File").Create<IFile>(Repository.RootFolder, "F1", ""); pFile.ConnectContent(true, "", "test.txt", contentUuid); });