【发布时间】:2017-01-24 23:38:55
【问题描述】:
当用户单击 UI 上的下载按钮时,我想下载共享中的文件。它适用于
filename = os.path.basename(pathToFile)
chunk_size = 8192
content_type = mime.from_file(pathToFile)
response = StreamingHttpResponse(FileWrapper(open(pathToFile), chunk_size),
content_type=content_type)
response['Content-Length'] = os.path.getsize(pathToFile)
response['Content-Disposition'] = 'attachment; filename="%s"' % filename
这里是javascript代码
$scope.downloadFile = function(path) {
return "/download_file?file=" + encodeURIComponent("somePath");
有什么建议吗?
【问题讨论】:
-
其他浏览器是否也出现此问题?
-
尝试使用
curl、wget或类似的命令行工具下载文件。然后您可能会看到问题所在,例如您的文件系统的最大文件大小可能为 1GB。 -
是的,在其他浏览器上也有同样的问题。我们正在使用 uwsgi 和 nginx。我在想我的默认配置只允许 1GB。我尝试使用 proxy_max_temp_file_size 5120m 添加 nginx conf;没有成功。
标签: javascript python angularjs download filesize