简体   繁体   English

SharePoint 2019 - 请求消息太大

[英]SharePoint 2019 - The request message is too big

I have a small Console Application made with the help of .NET Framework 4.7.2.我在 .NET Framework 4.7.2 的帮助下制作了一个小型控制台应用程序。 Its' purpose is to upload PDF files to a SharePoint 2019 site.其目的是将 PDF 文件上传到 SharePoint 2019 站点。 There is a 2 MB file size limitation which I cannot find a way to avoid.有一个 2 MB 的文件大小限制,我找不到避免的方法。 The error message is as follows:错误信息如下:

The request message is too big.请求消息太大。 The server does not allow messages larger than 2097152 bytes.服务器不允许大于 2097152 字节的消息。

I've tried what was suggested in this article -> https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/upload-large-files-sample-app-for-sharepoint我已经尝试了本文中的建议-> https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/upload-large-files-sample-app-for-sharepoint

The ContentStream property of the FileCreationInformation in Microsoft.SharePoint.Client is missing in my code.我的代码中缺少 Microsoft.SharePoint.Client 中FileCreationInformationContentStream属性。 I made sure that I am using the correct namespace and I also have the latest version of the dll.我确保我使用了正确的命名空间,并且我还拥有最新版本的 dll。 I later found out that the article is done on version 2013, so there is a big chance that the practises shows and outdated.后来我发现这篇文章是在 2013 版本上完成的,所以实践显示和过时的可能性很大。

This is the way I am trying to upload a file:这是我尝试上传文件的方式:

 Folder folder = context.Web.GetFolderByServerRelativeUrl(path);
 FileCreationInformation FileToUpload = new FileCreationInformation();
                    
 FileToUpload.Content = System.IO.File.ReadAllBytes(file.FullName);
 FileToUpload.Url = AccountList.RootFolder.ServerRelativeUrl + filePath);
 FileToUpload.Overwrite = true;

 folder.Files.Add(FileToUpload);
 folder.Update();
 AccountList.Update();
 context.ExecuteQuery();

As I already said, I wanted to use ContentStream property instead of Content to avoid the 2 MB exception but it may be outdated because I can't get this property.正如我已经说过的,我想使用ContentStream属性而不是Content来避免 2 MB 异常,但它可能已过时,因为我无法获得此属性。

My question is, is there any way to bypass the 2 MB file upload limitation?我的问题是,有没有办法绕过 2 MB 文件上传限制?

It turns out I had to install an additional Nuget package to see the ContentStream property of FileCreationInformation .事实证明,我必须安装一个额外的 Nuget package 才能看到FileCreationInformationContentStream属性。 My problem was immediately gone when I replaced Content property with ContentStream property.当我用ContentStream属性替换Content属性时,我的问题立即消失了。

Nuget Package Name: Microsoft.SharePoint2019.CSOM Nuget Package 名称:Microsoft.SharePoint2019.CSOM
Installation Command: Install-Package Microsoft.SharePoint2019.CSOM -Version 16.0.10337.12109安装命令: Install-Package Microsoft.SharePoint2019.CSOM -Version 16.0.10337.12109

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 请求URI太大 - Too big request URI 如果文件太大,则在Kendo Upload中返回正确的错误消息 - Returning correct error message in Kendo Upload if file too big 将大数据发送到 WCF - (413) 也请求实体 - Send Big Data to WCF - (413) Request Entity Too 将文件上传到Sharepoint返回413请求实体太大 - Uploading File to Sharepoint Returns 413 Request Entity Too Large 使用System.Net.Mail发送电子邮件时,如何捕获消息大小太大的异常? - How to catch message size too big exception when sending emails using System.Net.Mail? 序列化数据太大 - Serialize data is too big TableLayout中的图像按钮太大 - Imagebutton in TableLayout too big ftp上传太大了 - ftp upload is too big SharePoint 2019 Search REST API Is Returning 401 Unauthorized - When Called from C# Using Basic Authorization Request Header - SharePoint 2019 Search REST API Is Returning 401 Unauthorized - When Called from C# Using Basic Authorization Request Header Google Translate API如何使用.NET库翻译大文本((414)Request-URI太大) - Google Translate API How to translate big text ((414) Request-URI Too Large) with .NET library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM