Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 2013客户端对象模型文件大于2 Mb异常_Sharepoint_Sharepoint 2010_Sharepoint 2013_Sharepoint Clientobject - Fatal编程技术网

Sharepoint 2013客户端对象模型文件大于2 Mb异常

Sharepoint 2013客户端对象模型文件大于2 Mb异常,sharepoint,sharepoint-2010,sharepoint-2013,sharepoint-clientobject,Sharepoint,Sharepoint 2010,Sharepoint 2013,Sharepoint Clientobject,我不熟悉Sharepoint和客户端对象模型。我遇到了一个问题,无法解决该问题。我想在Sharepoint 2013中使用客户端对象模型上载超过10 MB的文件。我得到以下例外 请求消息太大。服务器不允许发送消息 大于2097152字节的 我什么都试过了。这是我做过的事情的清单 1-更改了本地web应用程序的web.config文件中的设置 <system.web> <httpRuntime useFullyQualifiedRedirectUrl="true" maxRequ

我不熟悉Sharepoint和客户端对象模型。我遇到了一个问题,无法解决该问题。我想在Sharepoint 2013中使用客户端对象模型上载超过10 MB的文件。我得到以下例外

请求消息太大。服务器不允许发送消息 大于2097152字节的

我什么都试过了。这是我做过的事情的清单

1-更改了本地web应用程序的web.config文件中的设置

<system.web>
<httpRuntime useFullyQualifiedRedirectUrl="true" maxRequestLength="2147483647" requestLengthDiskThreshold="2147483647" executionTimeout="18000"/> </system.web>

<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647" />
</requestFiltering>
</security>
</system.webServer>
这是我的密码:

private void UploadDataToSharepointTest(List<UploadData> pDataObjList)
    {
        string lServerUrl = @"http://xxxxxxx:2000/";
        string lFolderName = DateTime.Now.ToString(@"yyyyMMddHHmmss");


        ClientContext context = new ClientContext(lServerUrl);
        context.AuthenticationMode = ClientAuthenticationMode.Default;
        context.Credentials = new System.Net.NetworkCredential("user", "password", "domain");        

        Web web = context.Web;
        List docs = web.Lists.GetByTitle("ABC");
        Folder lNewFolder = web.Folders.Add(lServerUrl + "ABC/" + lFolderName + "/");
        docs.Update();

        int fileIndex = 1;
        foreach (var item in pDataObjList)
        {
            FileCreationInformation newFile = new FileCreationInformation();
            newFile.Content = System.IO.File.ReadAllBytes(item.CompleteFilePath);
            newFile.Url = fileIndex.ToString() + "-" + item.fileName;
            fileIndex++;

            Microsoft.SharePoint.Client.File uploadFile = lNewFolder.Files.Add(newFile);

            context.Load(uploadFile);
            context.ExecuteQuery();

            Dictionary<string, string> metadata = new Dictionary<string, string>();
            metadata.Add("Comments", item.comments);
            metadata.Add("Plan_x0020_Size", item.planSize);
            metadata.Add("Density", item.density);
            metadata.Add("First_x0020_Name", txtFirstName.Text.Trim());
            metadata.Add("Last_x0020_Name", txtLastName.Text.Trim());
            metadata.Add("Company", txtCompany.Text.Trim());
            metadata.Add("Contact", txtContact.Text.Trim());
            metadata.Add("Additional_x0020_Comments", txtAdditionalComments.Text.Trim());

            Microsoft.SharePoint.Client.ListItem items = uploadFile.ListItemAllFields;
            context.Load(items);
            context.ExecuteQuery();

            foreach (KeyValuePair<string, string> metadataitem in metadata)
            {
                items[metadataitem.Key.ToString()] = metadataitem.Value.ToString();
            }

            items.Update();
            context.ExecuteQuery();
        }

    }
private void UploadDataToSharepointTest(列表pDataObjList)
{
字符串lServerUrl=@”http://xxxxxxx:2000/";
字符串lFolderName=DateTime.Now.ToString(@“yyyyMMddHHmmss”);
ClientContext=新的ClientContext(lServerUrl);
context.AuthenticationMode=ClientAuthenticationMode.Default;
context.Credentials=new System.Net.NetworkCredential(“用户”、“密码”、“域”);
Web=context.Web;
列表文档=web.Lists.GetByTitle(“ABC”);
Folder lNewFolder=web.Folders.Add(lServerUrl+“ABC/”+lFolderName+“/”);
docs.Update();
int fileIndex=1;
foreach(pDataObjList中的var项)
{
FileCreationInformation newFile=新文件CreationInformation();
newFile.Content=System.IO.File.ReadAllBytes(item.CompleteFilePath);
newFile.Url=fileIndex.ToString()+“-”+item.fileName;
fileIndex++;
Microsoft.SharePoint.Client.File uploadFile=lNewFolder.Files.Add(新文件);
加载(上传文件);
context.ExecuteQuery();
字典元数据=新字典();
元数据。添加(“注释”,项目。注释);
元数据。添加(“计划大小”,项。计划大小);
元数据。添加(“密度”,项。密度);
Add(“First_x0020_Name”,txtFirstName.Text.Trim());
添加(“Last_x0020_Name”,txtLastName.Text.Trim());
Add(“Company”,txtCompany.Text.Trim());
Add(“Contact”,txtContact.Text.Trim());
metadata.Add(“附加注释”,txtAdditionalComments.Text.Trim());
Microsoft.SharePoint.Client.ListItems=uploadFile.ListItemAllFields;
上下文。加载(项目);
context.ExecuteQuery();
foreach(元数据中的KeyValuePair metadataitem)
{
items[metadataitem.Key.ToString()]=metadataitem.Value.ToString();
}
items.Update();
context.ExecuteQuery();
}
}

注意:我可以上传小文件

SharePoint允许您通过管理中心对此进行配置,我会坚持这样做,以确保它为您做出所有适当的更改。您需要具有场级权限。此外,在SharePoint 2013中,您可以为不同的文件类型设置不同的文件最大限制,因此请确保您的文件类型未被任何人更改


如果使用内置上载功能,则文件大小有限制

要上载大文件,请使用filestream进行上载

请看下面的文章:


此外,它可能是IIS设置。有关更多信息,请参阅本文。你找到解决办法了吗?
private void UploadDataToSharepointTest(List<UploadData> pDataObjList)
    {
        string lServerUrl = @"http://xxxxxxx:2000/";
        string lFolderName = DateTime.Now.ToString(@"yyyyMMddHHmmss");


        ClientContext context = new ClientContext(lServerUrl);
        context.AuthenticationMode = ClientAuthenticationMode.Default;
        context.Credentials = new System.Net.NetworkCredential("user", "password", "domain");        

        Web web = context.Web;
        List docs = web.Lists.GetByTitle("ABC");
        Folder lNewFolder = web.Folders.Add(lServerUrl + "ABC/" + lFolderName + "/");
        docs.Update();

        int fileIndex = 1;
        foreach (var item in pDataObjList)
        {
            FileCreationInformation newFile = new FileCreationInformation();
            newFile.Content = System.IO.File.ReadAllBytes(item.CompleteFilePath);
            newFile.Url = fileIndex.ToString() + "-" + item.fileName;
            fileIndex++;

            Microsoft.SharePoint.Client.File uploadFile = lNewFolder.Files.Add(newFile);

            context.Load(uploadFile);
            context.ExecuteQuery();

            Dictionary<string, string> metadata = new Dictionary<string, string>();
            metadata.Add("Comments", item.comments);
            metadata.Add("Plan_x0020_Size", item.planSize);
            metadata.Add("Density", item.density);
            metadata.Add("First_x0020_Name", txtFirstName.Text.Trim());
            metadata.Add("Last_x0020_Name", txtLastName.Text.Trim());
            metadata.Add("Company", txtCompany.Text.Trim());
            metadata.Add("Contact", txtContact.Text.Trim());
            metadata.Add("Additional_x0020_Comments", txtAdditionalComments.Text.Trim());

            Microsoft.SharePoint.Client.ListItem items = uploadFile.ListItemAllFields;
            context.Load(items);
            context.ExecuteQuery();

            foreach (KeyValuePair<string, string> metadataitem in metadata)
            {
                items[metadataitem.Key.ToString()] = metadataitem.Value.ToString();
            }

            items.Update();
            context.ExecuteQuery();
        }

    }