首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我可以上传一个2GB或更大的文件到SharePoint在线吗?

我可以上传一个2GB或更大的文件到SharePoint在线吗?
EN

Stack Overflow用户
提问于 2015-08-18 21:44:22
回答 1查看 919关注 0票数 0

我试图编写一个可以自动执行的C#应用程序,以便将2GB的.zip文件上传到Office365 SharePoint在线站点。然而,我似乎无法得到任何方法,我试图工作。经过多次徒劳无功的尝试,我一直在尝试使用"Lists.asmx“服务引用,这似乎很有希望,但无论我如何配置,我都会遇到异常。似乎应该有一个解决方案,如何使用C#?将单个2GB的.zip文件上传到SharePoint Online。

对于凭据,我只是使用了用于手动登录到SharePoint online的凭据。

下面的代码抛出由最后一个catch块捕获的异常,其中包含以下消息:

不理解SOAP头安全性

如果我使用ListsSoapClient(b, ea)而不是no arg构造函数,最后一个catch块会引发一个不同的异常,声明:

内容类型(windows-1252)与绑定内容类型(utf-8)不匹配。

另外,作为附带说明:,我假设ListsSoapClient() no-arg构造函数使用我在App.config文件?中指定的绑定

Program.cs

代码语言:javascript
运行
复制
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

代码语言:javascript
运行
复制
<?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>
EN

Stack Overflow用户

回答已采纳

发布于 2015-08-19 06:50:48

我认为你不能上传大文件到SharePoint在线。SharePoint Online的限制是最大文件2GB。

这是链接..。

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

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32083114

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档