Grace Note
Grace Note

Reputation: 3215

How do I distinguish a SharePoint file update as being from a file upload?

In SharePoint, when an item is first added to a document library, it fires the ItemAdded and ItemAdding events as expected. And if you upload the same filename to update the existing file, it will fire off ItemUpdated and ItemUpdating events, likewise as expected. However, I have been unsuccessful at determining whether this kind of action has actually occurred or not. Or, more specifically, I am entirely unable to differentiate between the following:

Is there actually a way to distinguish these kinds of updates? There appears to be nothing in event properties that contains this information, nor in the version history for both the list item and the file itself. I have even tried comparing the files themselves via OpenBinary(), but in both mentioned cases I still get the same result. Thank you in advance for any help!

Upvotes: 2

Views: 1304

Answers (1)

Jeroen Ritmeijer
Jeroen Ritmeijer

Reputation: 2792

I went through this same problem just over 2 years ago. The way I implemented it was by looking at all the fields in the before and after properties for both event types and some of the more obscure fields were different depending on the kind of event.

Unfortunately I don't have access to that code any more so I can't give you the name of the field. Just dump all the before and after properties and play around with it.

Painful, you'd think there would be an easier way. I had hoped that during the first upload the Before Properties would be null or empty, but no such luck.

Upvotes: 2

Related Questions