增加使用 Azure 部署的 K8s 集群中的最大文件上传大小(ASP.NET Core 中的项目 w/ C# 和 React)
Increase max file upload size in K8s Cluster deployed with Azure (Project in ASP.NET Core w/ C# and React)
如何增加 Azure 中的文件上传大小限制?它的上限约为 1MB。我尝试查看 Azure 门户中的各种设置,但找不到任何内容。我认为问题出在云环境上,因为我在本地没有问题。
我有一个 C# 网络应用程序,它使用 ASP.NET Core 和 React with .tsx。当我在本地 运行 程序时,我可以上传最大 28MB 的文件,这是 ASP.NET Core 的默认限制。但是,当我使用 Azure 部署到 K8s 集群(Kubernetes 服务)时,Web 应用程序只能上传大约 1MB 大小的文件。
我可以上传一个 984KB 的 .jpg 文件。当我尝试上传 1,043KB .png(或任何更大的文件)时,响应是
413 Request Entity Too Large
nginx/1.17.7
我看过 这是
The files object I was looping over in the posted code snippet was a IList type, which I was getting by casting the Request.Form.Files in the controller. Why I was doing this, I can't recall. Anyway, leaving the file list as the default IFormFileCollection that it gets bound to by MVC (the type on Request.Form.Files) seems to fix it. It also solved another problem I was having of certain file extensions not uploading.
但是,我使用 IFormFile
上传整个过程,没有转换。前端 .tsx 有一个带有 dropzone
输入组件的表单。变化事件e.currentTarget.files
returns一个FileList
。上传文件命令和控制器都独占使用 IFormFile
和 IFileSystem
.
您没有提供太多细节,所以我猜您使用的默认设置如下所示:
- 您有一个 nginx ingress 服务
- 您的应用 运行 支持此代理
正如您在错误消息中看到的那样,问题不在于您 asp.net 核心应用程序,而是它前面的 nginx ingress。
要解决它,您必须配置 nginx ingress 以允许更大的上传。
在我们的配置中,这看起来像这样
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/proxy-body-size: 500m
所以修复它的步骤:
- 更新您的入口清单文件
- 使用 kubectl 应用更改
文档:
如何增加 Azure 中的文件上传大小限制?它的上限约为 1MB。我尝试查看 Azure 门户中的各种设置,但找不到任何内容。我认为问题出在云环境上,因为我在本地没有问题。
我有一个 C# 网络应用程序,它使用 ASP.NET Core 和 React with .tsx。当我在本地 运行 程序时,我可以上传最大 28MB 的文件,这是 ASP.NET Core 的默认限制。但是,当我使用 Azure 部署到 K8s 集群(Kubernetes 服务)时,Web 应用程序只能上传大约 1MB 大小的文件。
我可以上传一个 984KB 的 .jpg 文件。当我尝试上传 1,043KB .png(或任何更大的文件)时,响应是
413 Request Entity Too Large
nginx/1.17.7
我看过
The files object I was looping over in the posted code snippet was a IList type, which I was getting by casting the Request.Form.Files in the controller. Why I was doing this, I can't recall. Anyway, leaving the file list as the default IFormFileCollection that it gets bound to by MVC (the type on Request.Form.Files) seems to fix it. It also solved another problem I was having of certain file extensions not uploading.
但是,我使用 IFormFile
上传整个过程,没有转换。前端 .tsx 有一个带有 dropzone
输入组件的表单。变化事件e.currentTarget.files
returns一个FileList
。上传文件命令和控制器都独占使用 IFormFile
和 IFileSystem
.
您没有提供太多细节,所以我猜您使用的默认设置如下所示:
- 您有一个 nginx ingress 服务
- 您的应用 运行 支持此代理
正如您在错误消息中看到的那样,问题不在于您 asp.net 核心应用程序,而是它前面的 nginx ingress。
要解决它,您必须配置 nginx ingress 以允许更大的上传。
在我们的配置中,这看起来像这样
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/proxy-body-size: 500m
所以修复它的步骤:
- 更新您的入口清单文件
- 使用 kubectl 应用更改
文档: