Django:文件上传 MemoryError 在 /some/url

发布于 2024-12-25 04:58:32 字数 354 浏览 3 评论 0原文

当我在服务器上部署后尝试上传大小超过 2 GB 的文件时,出现 MemoryError 异常,但在开发服务器上它工作正常。 应用程序由 Nginx + Gunicorn 提供服务,Nginx 对上传文件大小的限制约为 6Gb。 下面您可以看到处理上传的代码片段

destination = tempfile.NamedTempopraryFile(delete=False)
for chunk in f.chunks():
   destination.write(chunk)
destination.close()

临时文件会导致 MemoryError 异常吗?

I get a MemoryError exception when I try to upload files more than 2 gigs in size after the deployment on the server but with development server it works fine.
Application served by Nginx + gunicorn, Nginx limitation for uploaded file size is about 6Gb.
Below you can see the code fragment which handles uploading

destination = tempfile.NamedTempopraryFile(delete=False)
for chunk in f.chunks():
   destination.write(chunk)
destination.close()

Can a temporary file cause MemoryError exceptions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文