[英]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 中FileCreationInformation
的ContentStream
属性。 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 才能看到FileCreationInformation
的ContentStream
属性。 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.