从Flask下载文件时出现内存错误。 文件大小约为100兆字节。 我该如何修复它?
Flask下载代码
return send_from_directory(s_trash_path, s_zip_name, mimetype='zip', as_attachment=True)
错误代码
[2018-07-21 16:11:22,328] ERROR in app: Exception on /ec-fileupload/download/select [POST]
Traceback (most recent call last):
File "/home/venv_ec_fileupload/lib/python3.6/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/home/venv_ec_fileupload/lib/python3.6/site-packages/flask/app.py", line 1615, in full_dispatch_request
return self.finalize_request(rv)
File "/home/venv_ec_fileupload/lib/python3.6/site-packages/flask/app.py", line 1632, in finalize_request
response = self.process_response(response)
File "/home/venv_ec_fileupload/lib/python3.6/site-packages/flask/app.py", line 1856, in process_response
response = handler(response)
File "./app/__init__.py", line 170, in after_request
s_data = resp.get_data()
File "/home/venv_ec_fileupload/lib/python3.6/site-packages/werkzeug/wrappers.py", line 987, in get_data
rv = b''.join(self.iter_encoded())
MemoryError
response = Response(generate(),mimetype='application/zip') response.headers['Content-Type'] = "application/octet-stream" response.headers['Content-Disposition'] = "inline; filename=" + os.path.basename(s_path) return response
- undefined