我从weboage返回一个Excel.XLS文件,例如:
xls_response = HttpResponse(mimetype='application/vnd.ms-excel')
xls_response['Content-Disposition'] = 'attachment; filename=funfile.xls'
.
.
<code to generate the file - already accomplished>
.
.
return xls_response
一切正常,但我想在发送之前看看文件的大小,这样我就可以显示上次下载时的文件大小。我已经有一个模型可以存储它,但是我需要弄清楚如何在文件返回给客户机之前从xls_response object
获取文件大小。除了二进制数据的len()
之外,还有其他方法可以做到这一点吗?在
请参见下面的代码,记住django只是python
http://docs.python.org/2/library/sys.html#sys.getsizeof
相关问题 更多 >
编程相关推荐