开发者

SharePoint files MD5 hash

We have a client who requires that all image fil开发者_StackOverflow中文版es within SharePoint are stored in a manner that it can be shown they are a bit for bit copy of the originally uploaded file. Obviously, hashing the file would be able to show that when the file is retrieved.

What I haven't been able to find it any reference to someone implementing this functionality on a SharePoint image library. I've found numerous articles around implementing this generically in C#, but ideally I'd like to be able to do it on a standard SharePoint document/image library.

Does anyone have any suggestions as how best to go about doing this? Workflow comes to mind, but what do people think? Also, as a side to this, does anyone know whether or not SharePoint will store a bit for bit copy that will verify when we compare the checksum?


You can to implement a event handler which compute your file hash on upload and to store it in a metadata text field. It's a simple solution for your problem.


Why not use a Record Center site, they are designed for this sort of thing - verifiable archiving and storage.


I would add a "text" column to the image library and then implement the hashing logic in an event receiver. You will need two handlers - ItemAdded and ItemUpdated. The code will look something like

    public override void ItemAdded(Microsoft.SharePoint.SPItemEventProperties properties)
    {
        base.ItemAdded(properties);
        this.DisableEventFiring();
        properties.ListItem["myCustomField"] = this.CalculateHash(properties.ListItem.File);
        properties.ListItem.SystemUpdate();
        this.EnableEventFiring();
   }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜