SharePoint files MD5 hash - sharepoint

We have a client who requires that all image files 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();
}

Related

Google Docs: Table of content page numbers

we are currently building an application on the google cloud platform, which generates reports in Google Doc. For them, it is really important to have a table of content ... with page numbers. I know this is a feature request since a few years and there are add-ons (Paragraph Styles +, which didn't work for us) that provide this solution, butt we are considering to build this ourselves. if anybody has a suggestion on how we could start with this, it would be a great help!
thanks,
Best bet is to file a feature request on the product forums.
Currently the only way to do that level of manipulation of a doc to provide a custom TOC is to use Apps Script. It provides access to the document structure sufficient enough to build and insert a basic table of contents, but I'm not sure there's enough to do paging correctly (unless you force a page break on ever page...) There's no method to answer the question of "what page is this element on?"
Hacks like writing to a DOCX and converting don't work because TOCs are recognized for what they and show up without page numbers.
Of course you could write a DOCX or PDF with the TOC as you'd like and upload as a blob rather than as a Google Doc. They can still be viewed in Drive and such.

How Do You Create a Page that Selects and Clones part of a Document Library in Sharepoint 2007?

I am trying to set up a MySite allowing individuals to create and modify multiple projects, each which will contain a partial copy of a master Document Library. I have already created the Library and uploaded the documents, and I have a page on which I have been experimenting with how to do this.
I need to be able to display a list of the documents in the document library, allow the user to select which ones they want, and then when they click on a button, I need to initialize the database with some information about that prjoect, some information about each of the files, and the documents need to be copied to a new location, so that the user can pull them up and edit and save the changes that are specific to the one project. Also we will need to be able to be able to add/remove them through a similar interface after the project has already been created, if possible.
And, unfortunately, anything at all that uses code has been restricted; so, we can't use anything that will require anything to be installed in the GAC, and I can't even use any server-side scripts within the ASPX file. It seems like almost everything I find when I search for "Sharepoint 2007 clone Master Document Library" or the like involves using code.
I have been playing around with things in SharePoint designer for creating the UI, and I figured out how to get a list of the documents to show, although I'm having a hard time duplicating it. It created a <WebPartPages:DataFormWebPart> with a <SharePoint:SPDataSource> in it. However, when I've tried to pull over things like a Data View CheckBoxList to the document list, either it just won't let me drop it (this includes anywhere on the form, not just in the document list), or, as expected actually, it doesn't actually bind to each line of the list. It's not entirely clear to me what to do to create this.
I do get (more or less) that you can bind the controls via the .xslt in the form, but I'm figuring it's got to be simpler than writing them by hand since the designer looks so much like the Visual Studio designer. I am having a very hard time figuring out what exactly to do to get any of the controls to work, though; most of them have the same issue as the CheckBoxList and won't even drop on the form. I'm assuming there's a panel of some type, or some other thing, that I need to add to the form first, but this is so different from what I'm used to that I'm having a hard time even getting my bearings.
So, can someone point me in the right direction here? I'm going to need to be able to create the projects, select the documents, copy them over with some other information into a new project, including creating some items in the database. I have been developing software for a long time, on many different platforms with many different languages, although lately it's mainly been WinForms, with a fair bit of .aspx stuff (but nothing too fancy), and it's never been this hard. I figure there's just something I'm not getting about the model here; like, how do you tell the form you want to use x/y/z control connected to particular datasource? How do you tell sharepoint to create a new location for the files? How can you submit the selected files once you have them to Sharepoint and tell them where to copy to?
Any help would be so appreciated I have been tearing my hair out for days. :)
You might have had a change with SharePoint 2010, as there is a javascript/jQuery programming model, but without that you don't have a realistic of coding what you will need. You may get lucky and be able to call the SharePoint web services using jQuery, but it is going to be a lot of work to get around a "no code" requirement.
Okay, well, I was finally able to get this mostly working, although there are still some issues with displaying the data once I get it back; I will try to update this question once I have a better answer for that.
There's a cool library called SPServices which combines with JQuery to give an interface to the web services for SharePoint 2007. It seems to more or less provide an interface to anything that you need to do to use the web services without a lot of extra work on your part.
For example, to query a document library, I set up a function something like this in a helper class (based upon the examples from the SPServices documentation).
ServiceClass.prototype.getSpecialDocLib = function (onComplete) {
var sc = this;
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Special Document Library",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
var outTable = new DocTable();
$(xData.responseXML).find("[nodeName='z:row']").each(function () {
var i;
var outRow = new DocTableRow();
for (i = 0; i < this.attributes.length; ++i) {
outRow.addField(this.attributes[i].localName, this.attributes[i].value);
};
outTable.addRow(outRow);
});
sc.onDocumentListComplete(xData, Status);
if (onComplete != null)
onComplete(resultTable);
}
});
};
For copying a document library from one place to another, I believe you can use Lists.AddList to create it, (not specifically documented in SPServices but is based upon this Web Service call) either from scratch or a template, and I believe you can use the SPServices Copy.CopyIntoItemsLocal method.
Anyway, I seem to be making progress with this so far; I will update and accept this answer once I have a little more experience and time to make sure everything works, but so far I seem to be making progress toward the "no code" goal.

Export list of Sitecore items as Excel (or other formats)

I noticed that sitecore has the option of exporting users in an Excel format.
I need to have similar functionality for exporting 'participations', (a users can enlist to take part in an 'event', and if their entry is approved via a sitecore workflow, a 'participation' item is created in the content tree)
Since mostly everything in Sitecore is in essence based on items, and I want to export items to Excel, my question is - what are some of the best ways of doing this?
Questions:
Is there a way to re-use this functionality for regular items?
Would it be a good idea to create a custom admin page (any tips on doing this?) which has some custom code that reads the items from the database using the API?
are there sitecore plugins/shared source projects that can help me achieve this?
Or does anyone have a better idea? - would it be better to just store the participations in SQL? I'm mostly doing it this way because I want to make use of the 'free' functionality offers, for example workflow, but if that leads to me using anti-patterns please shoot me ;)
Link is different now: https://marketplace.sitecore.net/en/Modules/Advanced_System_Reporter.aspx
P.S. Couldn't leave a comment to original answer as I don't have enough reputation. Oh well :)
Found a most excellent shared source module which does exactly this (and much more)!
Basically it allows you to configure (and easily extend, if you need to) any kind of table based report on 'items'.
The report module shows up as an application in the sitecore menu (like the user manager tool) and comes with features such as xml,csv, xls export. It's also really easy to set up, once you get the hang of it.
http://trac.sitecore.net/AdvancedSystemReporter

Can I associate custom metadata with an ALAsset?

I'm building an iPhone app that, among other things, allows the user to take and store photographs associated with locations. I am currently using the ALAssetLibrary to allow the photographs to be stored in Photos and be accessible outside the app (on a computer for instance via the built-in mechanisms). There is not a lot of technical content out there for working with the ALAssetLibrary but from what there is I have managed to cobble together a working version of this. I have had to resort to storing a dictionary of photo URLS in my app and manually detecting if the photo still exists when displaying lists of them because there does not seem to be a way to add custom metadata to an ALAsset.
What I would really like to do is add two custom metadata fields to each asset to provide it with a title and a custom id value that I can use to filter on when enumerating the asset library.
As a secondary task, I'd like the user to be able to update the title metadata.
Can it be done? At this point, I really don't think it can because the API really doesn't seem to provide the necessary methods to get/set custom metadata. I'm hoping against all odds that there is some other aspect to the AssetLibrary framework that I have not yet discovered.
At a minimum, if someone can authoritatively say "NO" then at least others might find this breadcrumb on their own trail of hope and change tack more quickly!
And, having 0 reputation I can't tag it with AssetLibrary :( wow, this day is just going downhill. FML
I've been looking over the documentation and I dont think it is possible to tack on additional fields to the ALAsset object, well you can create your own object or extend theirs but that wont help you when your pulling back assets because you'll need to init yours and populate it then.
Look I know this falls short of a really good answer but I had to try.
The ALAsset class documentation describes a property - customMetadata. This is documented to be an NSDictionary of whatever custom tags you want. Currently, however, it is not implemented in the class (I've raised a bug on Apple's developer site to bring the issue up).

How to accurately determine if an SPFile instance is a converted file?

I have been working on a document conversion feature for converting a docx file to a pdf file using MOSS 2007. The SPFile.Convert() call is being made in the ItemAdded event and the ItemFileConverted event is fired fine as well. The eventing seems to be working fine, but the IsConvertedFile and SourceLeafName properties of the converted SPFile instance are not always set by the conversion process. This is what I was attempting to use to determine if a call to SPFile.Convert should be made.
In digging into the code for SPFile IsConvertedFile, GeneratingConverterId and SourceLeafName properties, it seems these are based on SPFile.Properties "vti_dttransformerid" and "vti_dtparentleafname". The problem is, these two properties are not being set consistently whenever I have code in my ISPConversionProcessor.PostProcess() implementation in which I was hoping to do some post processing of the file. If there is no code in the PostProcess method (only the runDefaultPostProcessing = true; statement) the properties are set more consistently.
I have some additional details here in a Wiki pageabout what is going on, but using .NET Reflector to determine where these fields are updated from hit a brick wall at OWSTIMER.EXE (I could find all of the reads for the properties, but even the HtmlLauncher and LoadBalancer services had no mention of these properties).
Has anyone done a complete Document Conversion implmentation and used the SPFile.IsConvertedFile and SPFile.SourceLeafName properties successfully?
If you can't trust the API, store the IsConverted metadata in the property bag for the SPListItem. Or if you prefer to show it in the UI, add another field to your list. This should all work fine from the event handler.
It's annoying to do the extra work but I guess there might be additional metadata that you can add which SPFile wouldn't have been able to provide anyway.
I have created a PDF Converter for SharePoint, but didn't use the Document Converter functionality as it didn't match our needs and was not flexible enough.
Not sure if this reply will be thrown out as spam as I am now going to link you to the place where you can download a free trial version. Download PDF Converter for SharePoint.
I feel a bit dirty now, but I may have actually helped you ;-)

Resources