每当我们尝试将大文件上传到Django后端:413 Payload too large时,我的团队就收到了413个错误。
我们不能确定最大可接受的文件大小-它似乎动摇在1-3 3MB范围内。
我们排除的东西:
./manage.py runserver和daphne -p 8000 topknott.asgi:application)上。photo = models.ImageField(blank=True)有人能发现我们错过了什么吗?
发布于 2019-05-28 09:54:14
Django建立了防止任何可疑活动的机制。
在settings.py文件中设置变量
DATA_UPLOAD_MAX_MEMORY_SIZE = 10*1024*1024 # your size limit in bytes见文档:大小
发布于 2019-12-26 20:43:19
发布于 2019-03-15 21:23:14
据我所知,runserver或daphne永远不会返回413。看起来在python服务器前面有NGINX。
可以使用client_max_body_size在nginx.conf中的服务器块中更改限制。
server {
client_max_body_size 20M;
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8000/;
}
}https://stackoverflow.com/questions/55190498
复制相似问题