我有一个 Django 应用程序,提供由在 Docker 容器中运行的 Nginx 提供支持的 React 静态文件。当我尝试通过我的网络应用程序上传一些较大的文件时,我不断413 Request entity too large直接从 Nginx接收
这是我的 Nginx 配置
/ # nginx -T
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile …Run Code Online (Sandbox Code Playgroud) 我正在制作练习网络服务(客户端的artbook显示网站)客户端可以将artbook图像上传到服务器.
但是当客户端上传太多图像时,我收到以下错误
413 Request Entity Too Large
Run Code Online (Sandbox Code Playgroud)
我尝试client_max_body_size 100M;在nginx.conf中添加
#user nobody;
#Defines which Linux system user will own and run the Nginx server
worker_processes 1;
#error_log logs/error.log; #error_log logs/error.log notice;
#Specifies the file where server logs.
#pid logs/nginx.pid;
#nginx will write its master process ID(PID).
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
server {
listen 80;
server_name xxxx.net;
client_max_body_size 100M;
keepalive_timeout 5;
return 301 https://$server_name$request_uri;
}
# HTTPS server …Run Code Online (Sandbox Code Playgroud) 将视频文件上传到 Amazon S3 时,文件上传达到 100%,然后我收到响应413 Request Entity Too Large。如何解决此问题以便我可以将视频文件上传到 Amazon S3?
我使用 Nodejs、Express、Heroku、Cloudflare 和 Amazon S3。
file-upload amazon-s3 node.js cloudflare http-status-code-413
当我尝试通过SSL向Asp.net Web API发送非常大的POST调用时,我收到此错误.
我知道重新谈判的现象.
我的uploadReadAheadSize设置为最大值.(2147483647)
谁能告诉我一些我应该尝试的选择?
以下是Chrome开发者控制台的请求和响应:

我也尝试了以下命令,没有结果:
C:\ Windows\System32\inetsrv\appcmd.exe set config"Web API"-section:system.webServer/ServerRuntime/enabled:"1024000"/ commit:apphost
C:\ Windows\System32\inetsrv\appcmd.exe set config"Web API"-section:system.webServer/ServerRuntime/uploadReadAheadSize:"1024000"/ commit:apphost
我有WCF服务,当我想将参数作为大字符串传递时,我有一个方法(超过1mb)
我运行此wcf并在WCF测试客户端中更改了配置,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyService" sendTimeout="00:05:00"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
当我尝试调用这个方法时,我仍然有413个请求实体太大了.
我想弄清楚如何在上传文件时处理 413 错误,to show the user that the file they are trying to upload is too large. 我正在使用React-dropzone从React 中的组件上传文件,然后将其传递给saga,然后sagas 中的函数将遍历文件并将每个文件发送到Rails - 使用Carrierwave上传文件,然后rails将发送回一些数据如果上传成功。
我的上传组件.jsx
this.state = {
files: [{file1}, {file2}, {file3}]
}
uploadFiles = () => {
this.props.saveFiles(this.state.files)
}
Run Code Online (Sandbox Code Playgroud)
sagas.js
function* saveFiles(action){
let err = false
let completed;
const results = yield Promise.all(action.files.map(function(file){
return saveFile(file)
})).then(data => {
completed = data
})
yield put({
type: actionTypes.FILE_UPLOADED, …Run Code Online (Sandbox Code Playgroud) 我在尝试将数据从 Web 应用程序 (.netfx 4.6.1) 发送到我的 Web api (.net core 3.1) 时遇到 413 问题。在下面的代码中,我发送了一个列表,其中包含图像的字节数据以及构建文件所需的附加数据。预期输出是返回包含新文件的字节数组。不幸的是,在发送请求时,我收到错误:响应状态代码未指示成功:413(请求实体太大)。
该错误似乎仅在文件一开始就很大时才会发生,这是有道理的。我所做的研究似乎指向 IIS 中的设置,主要是 maxAllowedContentLength、maxRequestLength 和 uploadReadAheadSize。我尝试将这些值增加到更适合此过程的值,但似乎没有任何效果。我已经针对 Web 应用程序和 Web api 调整了它们,因为我不确定是哪一个导致了问题。
问题出在哪里?在应用程序、API 或两者中?我是否缺少允许增加尺寸的附加设置?我发送请求的方式有问题吗?任何帮助表示赞赏。
public static async Task<byte[]> CreatePdfFromImageFilesAsync(List<ImageFile> imageFiles)
{
var list = new List<dynamic>();
foreach (var item in imageFiles)
{
list.Add(new
{
Data = Convert.ToBase64String(item.Bytes),
PageOrder = item.PageOrder,
Rotation = item.Rotation,
Type = "PDF"
});
}
var response = _client.PostAsJsonAsync($"{FileCreatorAPI}/api/files/CreateFileFromMultiple", list).Result;
var result = response.EnsureSuccessStatusCode();
var bytes = await result.Content.ReadAsAsync<byte[]>();
return bytes;
}
Run Code Online (Sandbox Code Playgroud) asp.net iis asp.net-web-api http-status-code-413 asp.net-core
我有一个文件上传处理程序,用于多个文件上传,并设置了MAX_CONTENT_SIZE.文档提到当文件总大小超过限制时,Flask会抛出413异常,因此我还编写了一个带有自定义413页面的413错误处理程序.但是,在测试文件上传时,我可以看到413错误肯定会被抛出,但连接似乎每次都会中断,而不是渲染我的错误页面.仅供参考,我目前正在使用Flask开发服务器.
码:
app.config['MAX_CONTENT_LENGTH'] = 50 * 1024 * 1024 # 50 Mb limit
@app.route('/upload', methods=['POST'])
def upload_files():
if request.method == 'POST':
uploaded_files = request.files.getlist('uploaded_files[]')
# do some stuff with these files
@app.errorhandler(413)
def error413(e):
return render_template('413.html'), 413
Run Code Online (Sandbox Code Playgroud)
更新:
好奇怪,这个问题似乎只发生在使用Flask开发服务器时.我在Apache上测试它,我的413错误页面渲染得很好.
我正在尝试使用 API v2 /upload 端点将文件上传到 Dropbox。有时我会收到来自 Dropbox 服务器的 413 错误响应(请求实体太大)。
不幸的是,文档中没有描述最大文件大小,也许有人知道吗?
每当我们尝试将大文件上传到Django后端时,我的团队都收到413错误: 413 Payload too large
我们无法确切确定可接受的最大文件大小-似乎在1-3MB范围内波动。
我们排除的内容:
这不是网络服务器配置问题,因为我们在
本地运行Django服务器(没有网络服务器)
我们认为这不是应用服务器配置问题,因为这在多个应用服务器(./manage.py runserver和
daphne -p 8000 topknott.asgi:application)上发生
看起来很正常的Django模型上的字段不是问题: photo = models.ImageField(blank=True)
谁能发现我们所缺少的东西?
django ×3
file-upload ×2
iis ×2
nginx ×2
reactjs ×2
amazon-s3 ×1
asp.net ×1
asp.net-core ×1
c# ×1
cloudflare ×1
docker ×1
dropbox-api ×1
flask ×1
node.js ×1
python ×1
redux ×1
ssl ×1
try-catch ×1
wcf ×1
wcf-binding ×1
webserver ×1