django setting.py
DATA_UPLOAD_MAX_MEMORY_SIZE
Default: 2621440
(i.e. 2.5 MB). 默认大小
The maximum size in bytes that a request body may be before a SuspiciousOperation
(RequestDataTooBig
) is raised. The check is done when accessing request.body
or request.POST
and is calculated against the total request size excluding any file upload data. You can set this to None
to disable the check. Applications that are expected to receive unusually large form posts should tune this setting.
The amount of request data is correlated to the amount of memory needed to process the request and populate the GET and POST dictionaries. Large requests could be used as a denial-of-service attack vector if left unchecked. Since web servers don’t typically perform deep request inspection, it’s not possible to perform a similar check at that level.
在引发可疑操作(RequestDataTooBig)之前,请求正文可能具有的最大字节数; 检查在访问时完成request.data或者request.POST并根据总请求大小(不包括任何文件上载数据)进行计算; 您可以将其设置为“None”以禁用检查(DATA_UPLOAD_MAX_MEMORY_SIZE = None)。希望接收异常大的表单帖子的应用程序应该调整此设置(DATA_UPLOAD_MAX_MEMORY_SIZE = 3621440000 # 设置上传请求的最大字节为3.37Gs)
请求数据量与处理请求和填充GET和POST字典所需的内存量相关; 如果不检查,大请求可以用作缓慢的HTTP攻击漏洞。因为web服务器通常不执行深度请求检查,不可能在该级别执行类似的检查
FILE_UPLOAD_MAX_MEMORY_SIZE
Default: 2621440
(i.e. 2.5 MB).
The maximum size (in bytes) that an upload will be before it gets streamed to the file system. See Managing filesfor details.
上传到文件系统之前的最大大小(字节)内存中的
据我所知,DATA_UPLOAD_MAX_MEMORY_SIZE应该不包括上传文件的大小,即那些request.FILES文件,但当设置为“FILE_UPLOAD_MAX_MEMORY_SIZE
”为默认值时,我可以上载文件,最大大小为“DATA\u UPLOAD\u MAX\u MEMORY”中设置的大小
上传到文件系统之前的最大大小(字节)。如果上传的文件大于FILE_UPLOAD_MAX_MEMORY_SIZE,文件的数据将流到FILE_UPLOAD_TEMP_DIR
FILE_UPLOAD_MAX_MEMORY_SIZE是内存缓存的大小
举个栗子:
DATA_UPLOAD_MAX_MEMORY_SIZE 设置为20M,FILE_UPLOAD_MAX_MEMORY_SIZE设置为15M。如果上载文件(25M),则会出现问题中的错误。所以,DATA_UPLOAD_MAX_MEMORY_SIZE改为30M,不会有错误。如果上传文件的数据大小小于15M,则数据在内存中。如果上传的大小超过15米,数据将流到磁盘。