In this article I will guide your through the process of uploading a document to any chosen document library in SharePoint 2010 through the Client Object Model.
This application has a very simple usage scenario:
- Type in the URL to your site where you want to upload your file
- Choose one of the available Document Libraries
- Click Upload a Document and you’ll get a browse-dialog to choose the file
How to utilize the Client Object Model in SharePoint 2010 to upload files
The most important thing to learn about when it comes to uploading files with the Client OM is to master the FileCreationInformation class that comes with the Client OM.
Take a look at this complete snippet to see how you can upload a file:
Things to note here is that I’m currently not changing the authentication for this application. That means it’ll be using your Windows/Domain Credentials.
Learn more about the authentication options here:
Summary, References & Download
With this sample application you can easily upload any file to any of your SharePoint 2010 document libraries by first entering the URL to the site, then selecting your library and finally browsing for a file and click OK.
Easily enough, you can change or extend this project the way you want it to work if you’ve got specific requirements to upload files using the Client OM.
You can download this sample project here.
Enjoy this piece of awesomeness :-)
Latest posts by Tobias Zimmergren (see all)
- Dev tip: Use Requestbin for easy analysis and debugging when developing your webhooks, connectors, API’s and applications - January 4, 2016
- Creating an ASP.NET 5 site with Visual Studio Code – Part 3: Adding npm packages and automating tasks with Gulp (adding Office UI Fabric) - October 4, 2015
- Creating an ASP.NET 5 site with Visual Studio Code – Part 2: Create your Visual Studio Code project using Yeoman - October 1, 2015