我的服务器基于 Django
,下面是我下载请求的响应。
...
stream_file = BytesIO()
pivot_df.reset_index()
pivot_df.to_excel(stream_file)
stream_file.seek(0)
response = StreamingHttpResponse(stream_file)
response['Content-Type'] = 'application/octet-stream;'
response['Content-Disposition'] = 'attachment; filename="{}.xlsx"'.format('account_data')
return response
响应大小约为 33.13MB
,一段时间后我的浏览器没有响应任何内容。它显示 Failed to load reponse data
。
Request URL: https: xxxxxx
Request Method: POST
Status Code: 200 OK
Remote Address: xxxxxx
Referrer Policy: strict-origin-when-cross-origin
但是如果我用 Postman
尝试这个请求,我可以获得正确的文件数据。
为什么我无法从浏览器下载 excel 文件。
谢谢。
我正在使用 Chrome 90.0.4430.93