VAF - Perform File Operations Before Check-In

Is there any way that I can get access to a file before a check-in is completed? I want to be able to use VAF to create a hash of the file which is being uploaded.

I have been trying to build a handler on the "MFEventHandlerBeforeCheckInChangesFinalize" event, but I can't access the file data as the file has not yet been committed at this step. I haven't been able to identify anything in the event handler properties that give me access to the file itself, even though this step should be after the file has been uploaded to the server.

Any assistance on how I can get a stream of the file data during the upload process so that I can set a property before committing the file would be greatly appreciated!

Cheers,

Matt

Parents
  • Unfortunately accessing the file data at that point is not something that is consistent to do.  You may instead need to post-process the file via something like a task queue.

  • Thanks Craig - is there a method at the point of checking in that will allow me to determine whether the data has changed in the file? I'm trying to avoid getting into situations where I'm constantly calculating the hash for a file which has had no changes (e.g., if file data is the same, and only metadata has changed).

    The other problem I'm having is that by using a task queue the server modifies the object, and I'm trying to avoid that re-triggering the task and getting stuck in an infinite loop.

  • There's a few ways to do this.

    The most basic way would be to always create a task in the AfterCheckInChangesFinalize event handler, then process the file in the task processor, but only update the object if the hash is different.  That's ugly because you still incur the cost of the processing, but...

    An extension of the above would be to check the file version data in the AftercheckInChangesFinalize event handler; if the file version has changed since the previous version then you need to queue the task, if it has not then you don't.

    I think.

  • Thanks Craig - I'm just having a bit of trouble finding a property that actually distinguishes between the files in current and previous versions. I've tried in the BeforeCheckInChangesFinalize  state to get the new version with:

    var oFiles = env.Vault.ObjectFileOperations.GetFiles(env.ObjVer);
    version = oFiles[1].FileVer;
    
    var previousObjVer = env.ObjVerEx.PreviousVersion;
    var previousFiles = env.Vault.ObjectFileOperations.GetFiles(previousObjVer);
    
    var previousVer = previousfiles[1].FileVer;

    What I'm finding though is that the version numbers are showing up as changed even when I just change the metadata (such as name) - is there a property that will specifically confirm changed versions.

    It's a little roundabout as this is essentially why I'm trying to get a hash for the file in the first place. The biggest problem I have with running the hash as a separate task in all instances is that I end up with historical versions that have a mismatch between the file contents and the hash.

Reply
  • Thanks Craig - I'm just having a bit of trouble finding a property that actually distinguishes between the files in current and previous versions. I've tried in the BeforeCheckInChangesFinalize  state to get the new version with:

    var oFiles = env.Vault.ObjectFileOperations.GetFiles(env.ObjVer);
    version = oFiles[1].FileVer;
    
    var previousObjVer = env.ObjVerEx.PreviousVersion;
    var previousFiles = env.Vault.ObjectFileOperations.GetFiles(previousObjVer);
    
    var previousVer = previousfiles[1].FileVer;

    What I'm finding though is that the version numbers are showing up as changed even when I just change the metadata (such as name) - is there a property that will specifically confirm changed versions.

    It's a little roundabout as this is essentially why I'm trying to get a hash for the file in the first place. The biggest problem I have with running the hash as a separate task in all instances is that I end up with historical versions that have a mismatch between the file contents and the hash.

Children