How to get the content of VaultClientFile?
Moderator: SourceGear
How to get the content of VaultClientFile?
I am creating a POC to Connect to Vault Server and Get All the files.
Put All the files in Database.
I have created a function RecursivelySearchForFileName()
I am able to get the VaultClientFile object, but not get the file content.
My client and server are on different locations.
I am using C# for developing this functionality.
Please help.
Put All the files in Database.
I have created a function RecursivelySearchForFileName()
I am able to get the VaultClientFile object, but not get the file content.
My client and server are on different locations.
I am using C# for developing this functionality.
Please help.
Re: How to get the content of VaultClientFile?
Can you post your code?
Beth Kieler
SourceGear Technical Support
SourceGear Technical Support
Re: How to get the content of VaultClientFile?
I am using this function to retrieve the list of files and folder of a particular folder
public void RecursivelySearch(VaultClientFolder folder, ref ArrayList returnArray, string folderUrl, VaultConnection vConn)
{
String url = folderUrl;
if (folder.Files.Count > 0)
{
//VaultRequestGetFile[] requests = null;
//string strDownloadID = "";
foreach (VaultClientFile subfile in folder.Files)
{
VaultFileProperties vFP = subfile.GetFileProperties();
//vConn.BeginDownloadFiles(Convert.ToInt32(subfile.ID), ref requests, ref strDownloadID);
//Ned here the content of file
returnArray.Add(subfile);
}
}
if (folder.Folders.Count > 0)
{
if (baseFolderUrl == "")
baseFolderUrl = ((VaultClientOperationsLib.VaultClientTreeObject)(folder)).FullPath;
foreach (VaultClientFolder subfolder in folder.Folders)
{
string folderPath = ((VaultClientOperationsLib.VaultClientTreeObject)(subfolder)).FullPath;
string finalFolder = folderPath.Replace(baseFolderUrl, url);
//Make entry in Database for this folder
RecursivelySearch(subfolder, ref returnArray, finalFolder, vConn);
}
}
}
string baseFolderUrl = "";
public void RecursivelySearch(VaultClientFolder folder, ref ArrayList returnArray, string folderUrl, VaultConnection vConn)
{
String url = folderUrl;
if (folder.Files.Count > 0)
{
//VaultRequestGetFile[] requests = null;
//string strDownloadID = "";
foreach (VaultClientFile subfile in folder.Files)
{
VaultFileProperties vFP = subfile.GetFileProperties();
//vConn.BeginDownloadFiles(Convert.ToInt32(subfile.ID), ref requests, ref strDownloadID);
//Ned here the content of file
returnArray.Add(subfile);
}
}
if (folder.Folders.Count > 0)
{
if (baseFolderUrl == "")
baseFolderUrl = ((VaultClientOperationsLib.VaultClientTreeObject)(folder)).FullPath;
foreach (VaultClientFolder subfolder in folder.Folders)
{
string folderPath = ((VaultClientOperationsLib.VaultClientTreeObject)(subfolder)).FullPath;
string finalFolder = folderPath.Replace(baseFolderUrl, url);
//Make entry in Database for this folder
RecursivelySearch(subfolder, ref returnArray, finalFolder, vConn);
}
}
}
string baseFolderUrl = "";
Re: How to get the content of VaultClientFile?
I am using Vault 5.0.2
Re: How to get the content of VaultClientFile?
If you are using the ServerOperations class to connect and find your files, you can just call one of the methods in GetOperations to download the file. GetOperations.ProcessCommandGetToLocationOutsideWorkingFolder, for example, would probably work for your purposes. If you aren't using ServerOperations, you can look at the code inside the methods of the GetOperations class for examples of how to use the corresponding ClientInstance methods directly.
Give that a look and let us know if you have more questions.
Give that a look and let us know if you have more questions.
Re: How to get the content of VaultClientFile?
Thanks Shannon.
Is there any way to get the stream/bytestream/byte[] of the file (without storing the file into Hard Drive).
Actually, within recursive method, if I found any file, I need the file stream at that moment and I will store that content in database.
Is there any way to get the stream/bytestream/byte[] of the file (without storing the file into Hard Drive).
Actually, within recursive method, if I found any file, I need the file stream at that moment and I will store that content in database.
Re: How to get the content of VaultClientFile?
Unfortunately no, you'll need to get it to disk and then stream it yourself from there.
Re: How to get the content of VaultClientFile?
I'm moving this topic over to the API forum.
Beth Kieler
SourceGear Technical Support
SourceGear Technical Support