[英]Remote Upload Sharepoint programatically using C#
Is it possible to remotely upload files using a Windows Application (C#) to Sharepoint Server? 是否可以使用Windows应用程序(C#)将文件远程上传到Sharepoint Server?
Thank you. 谢谢。
Yes, although you may need some of the SharePoint assemblies on the "remote" machine in order to achieve what you need. 是的,尽管您可能需要在“远程”计算机上使用某些SharePoint程序集来实现所需的功能。
Uploading files using Client Object Model in SharePoint 2010 is a pretty good starting point for SharePoint 2010. 在SharePoint 2010中使用客户端对象模型上载文件是SharePoint 2010的一个很好的起点。
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/ 如果您使用的是2007版本(WSS 3.0),则可以在此链接上找到有关上载文件的不同方法的摘要: http : //vspug.com/smc750/2009/05/19/uploading-content-into -sharepoint-LET-ME-数最的方式/
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. 如果服务器场是32位,则必须非常小心,在这种情况下,如果要并行上传大文件或许多文件,则很容易用完w3wp.exe进程中的所有可用内存,尤其是如果服务器场是忙一个。 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.
在那种情况下,您可能要使用上面链接中描述的RPC接口,因为这是唯一可以分块上传文件的接口。 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.
使用其他所有方法,必须先将要上传的整个文件加载到w3wp的内存中,然后再将其提交到SharePoint列表项。
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). 对于涉及SharePoint对象模型的方法,您可能需要编写自己的Web服务外观,以使没有SharePoint dll的客户端能够上传文件(如果需要,可以使用+元数据)。
You can use the client object model in sp2010, rather than talking to the web services directly. 您可以在sp2010中使用客户端对象模型,而不是直接与Web服务对话。
Taken from my upload profile picture applications: 取自我的上传个人资料图片应用程序:
http://spc3.codeplex.com/SourceControl/changeset/view/57957#1015709 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();
}
I wrote a tool available as a NuGet package in Visual Studio called SharePoint.DesignFactory.ContentFiles. 我在Visual Studio中编写了一个名为NuGet包的工具,称为SharePoint.DesignFactory.ContentFiles。 With this tool you can manage all files with metadata to be uploaded to the SharePoint content database.
使用此工具,您可以管理所有带有元数据的文件,这些文件将被上载到SharePoint内容数据库。 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.
您可以将其用于SharePoint 2007(当前必须在SharePoint机器本身上工作)或SharePoint 2010和Office365。在这种情况下,可以在未安装SharePoint的机器上工作。 See http://weblogs.asp.net/soever/archive/tags/SharePoint.DesignFactory.ContentFiles/default.aspx for blogposts on the tooling.
有关该工具的博客文章,请参见http://weblogs.asp.net/soever/archive/tags/SharePoint.DesignFactory.ContentFiles/default.aspx 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.