【问题标题】:How can I upload a file to a Sharepoint Document Library using Silverlight and client web-services?如何使用 Silverlight 和客户端 Web 服务将文件上传到 Sharepoint 文档库?
【发布时间】:2010-03-10 19:37:38
【问题描述】:

我遇到的大多数 Sharepoint 文档库上传解决方案都使用 HTTP“PUT”方法,但我在 Silverlight 中找不到执行此操作的方法,因为它对 HTTP 方法有限制。我访问了这个http://msdn.microsoft.com/en-us/library/dd920295(VS.95).aspx 以了解如何在我的代码中允许 PUT,但我找不到它如何帮助您使用 HTTP“PUT”。

我正在使用客户端 Web 服务,因此限制了一些可用的 Sharepoint 功能。

这给我留下了这些问题:

  1. 我可以在 Silverlight 中执行 http PUT 吗?
  2. 如果我不能上传文件或有其他更好的方法来上传文件,那是什么?

谢谢

【问题讨论】:

    标签: silverlight sharepoint upload


    【解决方案1】:

    想通了!!像魅力一样工作

        public void UploadFile(String fileName, byte[] file)
        {
            // format the destination URL
    
            string[] destinationUrls = {"http://qa.sp.dca/sites/silverlight/Answers/"+fileName}; 
    
            // fill out the metadata
            // remark: don't set the Name field, because this is the name of the document
    
            SharepointCopy.FieldInformation titleInformation = new SharepointCopy.FieldInformation
                {DisplayName =fileName, 
                 InternalName =fileName, 
                 Type = SharepointCopy.FieldType.Text, 
                 Value =fileName};
    
            // to specify the content type
    
            SharepointCopy.FieldInformation ctInformation = new SharepointCopy.FieldInformation
                {DisplayName ="XML Answer Doc", 
                 InternalName ="ContentType", 
                 Type = SharepointCopy.
                 FieldType.Text, 
                 Value ="xml"};
    
            SharepointCopy.FieldInformation[] metadata = { titleInformation }; 
    
            // initialize the web service
    
            SharepointCopy.CopySoapClient copyws = new SharepointCopy.CopySoapClient(); 
    
            // execute the CopyIntoItems method
            copyws.CopyIntoItemsCompleted += copyws_CopyIntoItemsCompleted;
            copyws.CopyIntoItemsAsync("http://null", destinationUrls, metadata, file);
        }
    

    非常感谢 Karine Bosch 提供的解决方案:http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/f135aaa2-3345-483f-ade4-e4fd597d50d4

    【讨论】:

      【解决方案2】:

      什么类型的 SharePoint 部署和什么版本的 silverlight?如果说这是一个 Intranet 部署,您可以使用 UNC 路径来访问 sharepoint 中的文档库和 Silverlight 3 中可用的 savefiledialog/openfiledialog。

      http://progproblems.blogspot.com/2009/11/saveread-file-from-silverlight-30-in.html

      http://www.kirupa.com/blend_silverlight/saving_file_locally_pg1.htm

      Silverlight 对它可以处理本地文件的操作有限制,尽管我听说 silverlight 4 有一些变化。

      http://www.wintellect.com/CS/blogs/jprosise/archive/2009/12/16/silverlight-4-s-new-local-file-system-support.aspx

      【讨论】:

      • 我会去看看。我正在使用 sl 3。部署很可能是 Intranet,但我不确定外部用户是否也需要使用它。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-21
      • 1970-01-01
      • 1970-01-01
      • 2010-10-31
      • 2012-12-21
      • 2010-09-21
      • 2013-12-12
      相关资源
      最近更新 更多