Click or drag to resize

FileContent Structure

Represents a sequence of binary data (BLOB) stored within a vault.

Namespace:  PDTec.IceNet.Core.Database
Assembly:  PDTec.IceNet.Core (in PDTec.IceNet.Core.dll) Version: 7.2.0.0 (7.2.7583.15464)
Syntax
C#
public struct FileContent

The FileContent type exposes the following members.

Methods
  NameDescription
Public methodEquals
Indicates whether this instance and a specified object are equal.
(Inherited from ValueType.)
Public methodGetHashCode
Returns the hash code for this instance.
(Inherited from ValueType.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns the fully qualified type name of this instance.
(Inherited from ValueType.)
Top
Fields
  NameDescription
Public fieldChangedBy
ID of the user who last changed the file content.
Public fieldChangedOn
Point of time the file content has been changed last
Public fieldCreatedBy
ID of the user who created the file content.
Public fieldCreatedOn
Point of time the file content has been created
Public fieldCryptoKey
The cryptographic key.
Public fieldHash
The file hash.
Public fieldSize
The file content size.
Public fieldUuid
The globally unique ID of the file content.
Public fieldVaultName
The vault name.
Top
Examples

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:

  • Create a FileContent record in the database and retrieve its UUID.
  • Upload the file content in several sequential steps.
  • Create the File object and connect the FileContent record.

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.

C#
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);
});
See Also