Confluence wiki有一种很好的存储附件的方法,可以将数百个文件上传到单个页面。每个页面就像一个页面内容和附件位于文件夹中的文件夹。可以通过转到工具>下载附件。附件并选择要下载的文件。为方便起见,可以选择全部下载。这会压缩所有文件并将其发送给将其视为带有随机名称的.zip的用户。
包含大量附件的页面存在问题,用户在工作时间下载这些附件会导致服务器负载过重。需要一种在工作时间禁用下载功能或禁止在工作时间创建大型zip文件的方法。
答案 0 :(得分:0)
修改confluence/confluence/pages/viewattachments.vm
并更改显示全部下载链接的逻辑,使其仅显示在购买时间之外。
要添加的代码:
## Only display Download All link during business hours ##
#set ($tdate = $action.dateFormatter.getCurrentDateTime() ) ## Get todays date
#set ($thour = $tdate.replaceAll(".* ([0-9]+):..", "$1") ) ## Extract the current hour value from the datetime string
#if (!$thour.matches("8|9|10|11|12|13|14"))
#if ($action.latestVersionsOfAttachments.size() > 1)
<a id="download-all-link" href="$req.contextPath/pages/downloadallattachments.action?pageId=$pageId" title="$action.getText('download.all.desc')">$action.getText('download.all')</a>
#end
#else
Download all attachments option only available outside of business hours.
#end ## $thour.matched end
这是要更改的代码块:
#if ($latestVersionsOfAttachments.size() > 0)
#set ($contextPath = "$req.contextPath/pages/viewpageattachments.action?pageId=$pageId&sortBy=$sortBy&")
#set ($sortPathPrefixHtml = "?pageId=$page.id&sortBy=")
#set ($showActions = "true")
#set ($old = "true")
#set ($attachmentHelper = $action)
#parse("/pages/includes/attachments-table.vm")
#if ($action.latestVersionsOfAttachments.size() > 1)
<a id="download-all-link" href="$req.contextPath/pages/downloadallattachments.action?pageId=$pageId" title="$action.getText('download.all.desc')">$action.getText('download.all')</a>
#end
#pagination($action.paginationSupport $contextPath)
#else
$action.getText('currently.no.attachments')
#end
以下是更改,以便全部下载链接仅在营业时间之外显示:
#if ($latestVersionsOfAttachments.size() > 0)
#set ($contextPath = "$req.contextPath/pages/viewpageattachments.action?pageId=$pageId&sortBy=$sortBy&")
#set ($sortPathPrefixHtml = "?pageId=$page.id&sortBy=")
#set ($showActions = "true")
#set ($old = "true")
#set ($attachmentHelper = $action)
#parse("/pages/includes/attachments-table.vm")
## Only display Download All link during business hours ##
#set ($tdate = $action.dateFormatter.getCurrentDateTime() ) ## Get todays date
#set ($thour = $tdate.replaceAll(".* ([0-9]+):..", "$1") ) ## Extract the current hour value from the datetime string
#if (!$thour.matches("8|9|10|11|12|13|14"))
#if ($action.latestVersionsOfAttachments.size() > 1)
<a id="download-all-link" href="$req.contextPath/pages/downloadallattachments.action?pageId=$pageId" title="$action.getText('download.all.desc')">$action.getText('download.all')</a>
#end
#else
Download all attachments option only available outside of business hours.
#end ## $thour.matched end