0

Is it possible to remotely upload files using a Windows Application (C#) to Sharepoint Server?

Thank you.

Nishant
  • 905
  • 1
  • 16
  • 36
  • Which version of SharePoint are you targeting? – ZombieSheep Mar 03 '11 at 13:55
  • 2
    possible duplicate of [Upload a file to SharePoint through the built-in web services](http://stackoverflow.com/questions/31868/upload-a-file-to-sharepoint-through-the-built-in-web-services) – Scott Saad Mar 03 '11 at 14:40
  • more info: http://stackoverflow.com/questions/450915/upload-files-to-sharepoint-document-libraries-via-ftp or possibly another dupe of: http://stackoverflow.com/questions/468469/how-do-you-upload-a-file-to-a-document-library-in-sharepoint – Kit Menke Mar 03 '11 at 14:54

4 Answers4

2

Yes, although you may need some of the SharePoint assemblies on the "remote" machine in order to achieve what you need.

Uploading files using Client Object Model in SharePoint 2010 is a pretty good starting point for SharePoint 2010.

shadi
  • 358
  • 6
  • 15
ZombieSheep
  • 29,603
  • 12
  • 67
  • 114
1

In case you are using the 2007 version (WSS 3.0), you can find a great summary of different ways to upload files on this link: http://vspug.com/smc750/2009/05/19/uploading-content-into-sharepoint-let-me-count-the-ways/

You must be very careful if your farm is 32bit, in that case it is very easy to use up all the available memory in the w3wp.exe process if you're uploading large files or many files in parallel, especially if the farm is a busy one. In that case you might want to use the RPC interface described in the link above, since this is the only one where you can upload files in chunks. With all other ways the entire file being uploaded must first be loaded in the w3wp's memory before it's committed to the SharePoint list item.

For ways that involve SharePoint object model, you might want to write your own web service facade to enable the clients that do not have SharePoint dlls to upload files (+ metadata if you need it).

Robert Seso
  • 201
  • 1
  • 3
  • Do we need to have sharepoint installed in the remote machine? – Nishant Mar 04 '11 at 09:55
  • Thanks a lot Robert. This is a great link. I tried implementing the WebDAV method (the easiest of all) and it worked. What I am confused is about the method where we use the Sharepoint dll reference. It keeps giving me an error saying it cannot load the assemble. Is it that I need sharepoint installed in my machine? – Nishant Mar 04 '11 at 12:18
  • Which assemblies failed to load? Normally WebClient class should not fail to load since it is a part of .NET framework... – Robert Seso Mar 04 '11 at 22:16
  • WebClient worked fine. It was ssocli.dll which was creating a problem – Nishant Mar 07 '11 at 12:26
1

You can use the client object model in sp2010, rather than talking to the web services directly.

Taken from my upload profile picture applications:

http://spc3.codeplex.com/SourceControl/changeset/view/57957#1015709

        using (ClientContext context = new ClientContext(siteurl)) {
            context.AuthenticationMode = ClientAuthenticationMode.Default;
            List list = context.Web.Lists.GetByTitle(listname);
            context.Load(list);
            context.Load(list.RootFolder);
            context.ExecuteQuery();
            string url = siteurl.CombineUrl(list.RootFolder.ServerRelativeUrl).CombineUrl(listfolder).CombineUrl(name);
            FileCreationInformation fci = new FileCreationInformation();
            fci.Content = data;
            fci.Overwrite = true;
            fci.Url = url;
            Microsoft.SharePoint.Client.File file = list.RootFolder.Files.Add(fci);
            context.ExecuteQuery();
        }
djeeg
  • 6,685
  • 3
  • 25
  • 28
0

I wrote a tool available as a NuGet package in Visual Studio called SharePoint.DesignFactory.ContentFiles. With this tool you can manage all files with metadata to be uploaded to the SharePoint content database. You can use this for SharePoint 2007 (currently have to work on the SharePoint machine itself) or for SharePoint 2010 and Office 365. In this case you can work from a machine without SharePoint installed. See http://weblogs.asp.net/soever/archive/tags/SharePoint.DesignFactory.ContentFiles/default.aspx for blogposts on the tooling.

Serge van den Oever
  • 4,340
  • 8
  • 45
  • 66