如何使用 Silverlight 和客户端 Web 服务将文件上传到 Sharepoint 文档库? [英] How can I upload a file to a Sharepoint Document Library using Silverlight and client web-services?
问题描述
我遇到的大多数 Sharepoint 文档库上传解决方案都使用 HTTPPUT"方法,但我在 Silverlight 中找不到执行此操作的方法,因为它对 HTTP 方法有限制.我访问了这个 http://msdn.microsoft.com/en-us/library/dd920295(VS.95).aspx 查看如何在我的代码中允许 PUT,但我找不到它如何帮助您使用 HTTPPUT".
Most of the solutions I've come across for Sharepoint doc library uploads use the HTTP "PUT" method, but I'm having trouble finding a way to do this in Silverlight because it has restrictions on the HTTP Methods. I visited this http://msdn.microsoft.com/en-us/library/dd920295(VS.95).aspx to see how to allow PUT in my code, but I can't find how that helps you use an HTTP "PUT".
我正在使用客户端网络服务,因此限制了一些可用的 Sharepoint 功能.
I am using client web-services, so that limits some of the Sharepoint functions available.
这给我留下了以下问题:
That leaves me with these questions:
- 我可以在 Silverlight 中执行 http PUT 吗?
- 如果我不能上传文件,或者有其他更好的方法来上传文件,那是什么?
谢谢
推荐答案
想通了!!就像一个魅力
Figured it out!! works like a charm
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
Many Thanks to Karine Bosch for the solution here: http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/f135aaa2-3345-483f-ade4-e4fd597d50d4
这篇关于如何使用 Silverlight 和客户端 Web 服务将文件上传到 Sharepoint 文档库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!