簡體   English   中英

我可以將2GB或更大的文件上傳到SharePoint Online嗎?

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

我正在嘗試編寫一個可以自動執行的C#應用​​程序,以將2 GB的.zip文件上載到Office365 SharePoint Online網站。 但是,我似乎無法獲得嘗試的任何方法。 經過許多無果的嘗試之后,我一直致力於使用“ Lists.asmx”服務參考,該參考似乎很有希望,但是無論如何配置,我都會不斷收到異常。 似乎應該為此提供解決方案, 如何使用C#將一個2 GB的.zip文件上傳到SharePoint Online?

對於憑據,我只是一直使用用於手動手動登錄到SharePoint的憑據。

下面的代碼在消息的最后一個catch塊中引發異常:

不了解SOAP標頭安全性

如果我使用ListsSoapClient(b, ea)而不是no arg構造函數,則最后一個catch塊將拋出一個不同的異常,說明:

內容類型(windows-1252)與綁定內容類型(utf-8)不匹配

另外,作為一個補充說明: 我假設ListsSoapClient()no-arg構造函數使用在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/zh-CN/article/SharePoint-Online-and-OneDrive-for-Business-software-boundaries-and-limits-8f34ff47-b749-408b-abc0-b605e1f6d498?ui=zh- US&rs = zh-CN&ad = SG

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM