问题
Can someone please advise on uploading files to Office365 SharePoint?
I believe this should be done using the DAV protocol, so HTTP::DAV should be right library for that, but how to code it to make it work with Office365? Each account hosted with Office365 has a TeamSite website, which hopefully can be accessible with DAV. Please advise.
回答1:
Upload large documents to SharePoint site using WebClient class gives an example of using DAV to upload a document.
WebClient oWebClient = new WebClient();
oWebClient.UseDefaultCredentials = true;
byte[] bFile = System.IO.File.ReadAllBytes(@"C:\Sundar\WEB315.wmv");
string ulr = @"http://lt010593/Shared Documents/WEB315.wmv";
System.Uri oUri = new System.Uri(ulr);
oWebClient.UploadDataAsync(oUri, "PUT", bFile);
oWebClient.UploadDataCompleted += new UploadDataCompletedEventHandler(oWebClient_UploadDataCompleted);
With that example in mind, the task is to look at WebClient documentation to figure out what oWebClient.UseDefaultCredentials = true; really does.
Set this property to true when requests made by this WebClient object should, if requested by the server, be authenticated using the default credentials of the currently logged on user. For client applications, this is the desired behavior in most scenarios. For middle tier applications, such as ASP.NET applications, instead of using this property, you would typically set the Credentials property to the credentials of the client on whose behalf the request is made.
So, it seems, the task is to figure out what credential information is sent. The rest seems to be a simple PUT
request.
来源:https://stackoverflow.com/questions/11658024/how-can-i-upload-files-to-office365-sharepoint-with-perl