什么是最好的方式将文件上载到一个文件库SharePoint服务器上通过的建立在网络服务,版本的鞋3.0公开?

以下两个初步的答案...

  • 我们肯定需要使用网络服务一层作为我们将作出这些呼吁,从远程客户的应用。

  • WebDAV方法将为我们工作,但我们更希望是一致的网络服务一体化的方法。

还有另外一个网服务来传文件,痛苦的,但工作的所有时间。

你是指"复制"服务吗?我们已经成功地与这一服务的 CopyIntoItems 法。这是所建议的方式将文件上传到文件图书馆只使用鞋网服务API?

我已经发布我们的代码作为一个建议的答复。

有帮助吗?

解决方案

例的使用鞋"复制"的网络服务,以上文件图书馆...

public static void UploadFile2007(string destinationUrl, byte[] fileData)
{
    // List of desination Urls, Just one in this example.
    string[] destinationUrls = { Uri.EscapeUriString(destinationUrl) };

    // Empty Field Information. This can be populated but not for this example.
    SharePoint2007CopyService.FieldInformation information = new 
        SharePoint2007CopyService.FieldInformation();
    SharePoint2007CopyService.FieldInformation[] info = { information };

    // To receive the result Xml.
    SharePoint2007CopyService.CopyResult[] result;

    // Create the Copy web service instance configured from the web.config file.
    SharePoint2007CopyService.CopySoapClient
    CopyService2007 = new CopySoapClient("CopySoap");
    CopyService2007.ClientCredentials.Windows.ClientCredential = 
        CredentialCache.DefaultNetworkCredentials;
    CopyService2007.ClientCredentials.Windows.AllowedImpersonationLevel = 
        System.Security.Principal.TokenImpersonationLevel.Delegation;

    CopyService2007.CopyIntoItems(destinationUrl, destinationUrls, info, fileData, out result);

    if (result[0].ErrorCode != SharePoint2007CopyService.CopyErrorCode.Success)
    {
        // ...
    }
}

其他提示

另一个选择是使用纯ol'HTTP放:

WebClient webclient = new WebClient();
webclient.Credentials = new NetworkCredential(_userName, _password, _domain);
webclient.UploadFile(remoteFileURL, "PUT", FilePath);
webclient.Dispose();

在remoteFileURL点SharePoint文献图书馆。

有几件事情要考虑:

  • 复制。CopyIntoItems 需要的文件已经存在一些服务器.该文件是通过作为一个参数的服务电话,这将限制有多大的文件即可。(见 http://social.msdn.microsoft.com/Forums/en-AU/sharepointdevelopment/thread/e4e00092-b312-4d4c-a0d2-1cfc2beb9a6c)
  • 'http放方法(即webdav...)只会把该文件在图书馆,但没有设置场价值
  • 更新领域值你可以打电话的清单。UpdateListItem后'http放'
  • 文件库的目录,可以使它们与'http mkcol'
  • 你可能需要检查,在文件清单。CheckInFile
  • 你也可以创建一个自定义服务使用的SPxxx.净API,但是,新的服务将被安装在服务器上。它可以节省旅行服务器。
public static void UploadFile(byte[] fileData) {
  var copy = new Copy {
    Url = "http://servername/sitename/_vti_bin/copy.asmx", 
    UseDefaultCredentials = true
  };

  string destinationUrl = "http://servername/sitename/doclibrary/filename";
  string[] destinationUrls = {destinationUrl};

  var info1 = new FieldInformation
                {
                  DisplayName = "Title", 
                  InternalName = "Title", 
                  Type = FieldType.Text, 
                  Value = "New Title"
                };

  FieldInformation[] info = {info1};
  var copyResult = new CopyResult();
  CopyResult[] copyResults = {copyResult};

  copy.CopyIntoItems(
    destinationUrl, destinationUrls, info, fileData, out copyResults);
}

注: 改变第1次参数 CopyIntoItems 文件名称, Path.GetFileName(destinationUrl), ,使取消的消息消失。

我有好运气的使用DocLibHelper包装类描述: http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html

从一个可以在工作:

懒惰的方式:你的Windows WebDAV文件系统接口。它是糟糕的一个方案解决方案,因为它依赖于WindowsClient服务上运行的操作系统,并且还只能在网站上运行,港口的80个。地图驱动的文件库,并获得文件复制。

还有另外一个网服务来传文件,痛苦的,但工作的所有时间。

我相信你能够上载的文件通过的FrontPage API但我不知道的任何人实际上使用它。

不能确定到底是哪网服务的使用,但是如果你是一个位置,可以使用SharePoint。净API Dll,然后使用SPList和SPLibrary.的项目。添加真的很容易。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top