我可以上传2GB或更大的文件到SharePoint Online吗?
本文关键字:文件 SharePoint Online 2GB 我可以 | 更新日期: 2023-09-27 18:08:40
我正在尝试编写一个c#应用程序,可以自动执行上传一个2gb的.zip文件到Office365 SharePoint Online网站。然而,我似乎不能得到任何方法,我试图工作。在多次无果而终的尝试之后,我开始使用"清单"。asmx"服务引用,它看起来很有希望,但是无论我如何配置,我总是得到异常。似乎应该有一个解决方案在那里,我怎么能上传一个单一的2gb .zip文件到SharePoint在线使用c# ?
对于凭证,我只是使用手动登录到SharePoint在线时使用的凭证。
下面的代码抛出一个由最后一个catch块捕获的异常,消息为:
SOAP header Security was not understand
如果我使用ListsSoapClient(b, ea)
而不是无参数构造函数,则抛出一个不同的异常,由最后一个catch块捕获,声明:
内容类型(windows-1252)与绑定内容类型(utf-8)不匹配
另外,作为旁注:我假设ListsSoapClient()无参数构造函数使用我在App.config文件中指定的绑定?
Program.cs
string srcUrl = @"testingBACKUP.zip";
FileStream fStream = File.OpenRead(srcUrl);
string fileName = fStream.Name.Substring(3);
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
EndpointAddress ea = new EndpointAddress("https://companyname.sharepoint.com/");
WSHttpBinding b = new WSHttpBinding();
b.Security.Mode = SecurityMode.TransportWithMessageCredential;
//b.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
ListsSoapClient listService = new ListsSoapClient();//b, ea);
listService.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
listService.ClientCredentials.UserName.UserName = "<username>";
listService.ClientCredentials.UserName.Password = "<password>";
try
{
var testing = listService.GetListContentType("Company", "windows-1252");
string addAttach = listService.AddAttachment("Company", "1", fileName, contents);
}
catch (System.Web.Services.Protocols.SoapException ex)
{
// catch error
}
catch (Exception e)
{
}
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ListsSoap"
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2000000" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://companyname.sharepoint.com/_vti_bin/Lists.asmx"
binding="basicHttpBinding" bindingConfiguration="ListsSoap"
contract="SharePointListsReference.ListsSoap" name="ListsSoap" />
</client>
</system.serviceModel>
</configuration>
我认为你不能上传大文件到SharePoint Online。SharePoint Online的最大限制是2GB。
https://support.office.com/en - sg/article/sharepoint在线-和- onedrive - -业务-软件-边界和限制- 8 f34ff47 b749 - 408 b - abc0 b605e1f6d498?ui=en us& rs = en-SG&广告= SG