I am trying to figure out how to access a thumbnail of a Vault file. I want to use this code from Doug Redmond, but what I need to know is how to get the 'Document.PropInst propInst' value to pass to the function. I have a 'VDF.Vault.Currency.Entities.FileIteration' object in my code that is holding the file whose thumbnail I want to access, but how do connect the two together?
Solved! Go to Solution.
Solved by Redmond.D. Go to Solution.
From your Connection object, try calling PropertyManager.GetPropertyValue. I think this will give you the byte array for the thumbnail.
Use PropertyManager.GetPropertyDefinitions to locate the thumbnail PropertyDefinition object.
Also, the link you posted is to the old thumbnail algorithm. For Vault 2012 and higher, you should use the new thumbnail algorithm.
ok, thanks for that info, does this look close to right? I'm also having trouble setting up the propertyValueSettings value. Do you have any sample code at all?
Thanks a lot for your help.
public void getThumbNail(VDF.Vault.Currency.Entities.FileIteration file) { VDF.Vault.Currency.Properties.PropertyDefinitionDictionary propDict = vConnection.PropertyManager.GetPropertyDefinitions("FILE", VDF.Vault.Currency.Entities.EntityCategory.EmptyCategory, VDF.Vault.Currency.Properties.PropertyDefinitionFilter.IncludeAll); VDF.Vault.Currency.Properties.PropertyValueSettings propSettings = new VDF.Vault.Currency.Properties.PropertyValueSettings(); VDF.Vault.Currency.Properties.PropertyDefinition propDefinition = new VDF.Vault.Currency.Properties.PropertyDefinition(); propDefinition = propDict.SingleOrDefault(x => x.Key == "Thumbnail").Value; //propSettings = ???? vConnection.PropertyManager.GetPropertyValue(file,propDefinition,propSettings);
You can pass in null for the settings when calling GetPropertyValue. It will return a ThumbnailInfo object, which has the byte array in it. See sample code below.
PropertyDefinition thumbnailPropDef = m_conn.PropertyManager.GetPropertyDefinitionBySystemName("Thumbnail");
ThumbnailInfo thumbnailInfo = m_conn.PropertyManager.GetPropertyValue(fileIter, thumbnailPropDef, null) as ThumbnailInfo;
byte [] thumbnailBytes = thumbnailInfo.Image;