我可以将 2GB 或更大的文件上传到 SharePoint Online 吗?

Can I upload a 2GB or larger file to SharePoint Online?

我正在尝试编写一个可以自动执行以将 2 GB .zip 文件上传到 Office365 SharePoint Online 站点的 C# 应用程序。但是,我似乎无法获得任何尝试工作的方法。经过多次无果而终的尝试后,我一直在深入研究使用 "Lists.asmx" 服务参考,这看起来很有希望,但无论我如何配置,我都会不断收到异常。似乎应该有一个解决方案,如何使用 C# 将单个 2 GB .zip 文件上传到 SharePoint Online?

对于凭据,我一直在使用我用来手动登录 SharePoint online 的凭据。

下面的代码抛出一个由最后一个 catch 块捕获的异常,消息为:

SOAP header Security was not understood

如果我使用 ListsSoapClient(b, ea) 而不是无参数构造函数,则最后一个 catch 块会抛出一个不同的异常:

the content type (windows-1252) does not match the binding content type (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。

这是 link...

https://support.office.com/en-sg/article/SharePoint-Online-and-OneDrive-for-Business-software-boundaries-and-limits-8f34ff47-b749-408b-abc0-b605e1f6d498?ui=en-US&rs=en-SG&ad=SG