Click or drag to resize

DatabaseUtilsCreateFileContentBeforeConnectTransaction Method (IDatabaseRepository, String, String, Int32)

Creates a file content from binary content outside a database transaction. This avoids delaying the transaction commit because of possible network communication issues during uploading the binary content to the vault.

Namespace:  PDTec.IceNet.Sdk.Utils
Assembly:  PDTec.IceNet.Sdk (in PDTec.IceNet.Sdk.dll) Version: 7.2.0.0 (7.2.7583.15464)
Syntax
C#
public static string CreateFileContentBeforeConnectTransaction(
	IDatabaseRepository pRepository,
	string vaultName,
	string filePath,
	int maxChunkSize = 10485760
)

Parameters

pRepository
Type: PDTec.IceNet.Core.DatabaseIDatabaseRepository
The database repository.
vaultName
Type: SystemString
The vault name.
filePath
Type: SystemString
The file to be transferred to the vault.
maxChunkSize (Optional)
Type: SystemInt32
The maximum chunk size used to perform a multipart transfer. Actual chunk size might be further reduced by vault protocol limit.

Return Value

Type: String
The content UUID of the new file content record.
Remarks
This method starts and commits its own (small) transaction to create the file content record. It must not be called inside a transaction.
Examples

The example shows how to use the CreateFileContentBeforeConnectTransaction(IDatabaseRepository, String, String, Int32) method to create a file content and connect this file content in a database transaction.

// 
// First step: create a FileContent record...
// 

string contentUuid = DatabaseUtils.CreateFileContentBeforeConnectTransaction(Repository, "System.Database", "koala.jpg");

// 
// 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, "", "koala.jpg", contentUuid);
});
See Also