Confluence Docs 3.3 : Disabling Attachment Downloads
This page last changed on Mar 31, 2010 by akdominguez.
At the moment, permissions for downloading attachments can't be set. To disable attachment downloading you need to edit your velocity files. Attachments can currently be downloaded in two separate ways: by viewing the attachments for a page, and by viewing all the attachments for a Space (Browse > Attachments).
Attachments for a whole SpaceTo disable downloading attachments from a Space, you need to edit the listattachmentsforspace.vm file. Delete or comment out the following line <td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> <a href="$req.contextPath$!attachment.downloadPathWithoutVersion">$generalUtil.shortenString($attachment.fileName, 50)</a></td> and replace it with either of the following two code blocks: Disabling downloading for all attachments<td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> $generalUtil.shortenString($attachment.fileName, 50)</td> Disabling downloading for specific file types#set($disabledDownloads = ['ext1', 'ext2']) #set($disabled = false) #set($attachmentExtension = $attachment.fileExtension) <tr id="attachment_$!attachment.id"> #foreach($doNotDownload in $disabledDownloads) #if($attachmentExtension == $doNotDownload) #set($disabled = true) #break #end #end #if(!$disabled) <td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> <a href="$req.contextPath$!attachment.downloadPathWithoutVersion">$generalUtil.shortenString($attachment.fileName, 50)</a></td> #else <td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> $generalUtil.shortenString($attachment.fileName, 50)</td> #end To specify which files you want disabled, change the 'ext1', 'ext2' in the first line to the extensions for which you want to disable downloading. You can specify as many extensions as you want, as long as they are in quotes, are comma separated and do not include the '.' at the start. For example, if I did not want users to download .jpg and .doc and .png files, the line would read #set($disabledDownloads = ['jpg', 'doc', 'png']) Attachments for a specific page
To disable downloading attachments from a specific page, you need to edit the attachments-table.vm file. Delete or comment the line <a class="filename" href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")" title="$generalUtil.htmlEncodeAndReplaceSpaces($attachment.fileName)" >$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35))</a> and replace it with either of the following two code blocks: Disabling downloading for all attachments$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35)) Disabling downloading for specific file types#set($disabledDownloads = ['ext1', 'ext2']) #set($disabled = false) #set($attachmentExtension = $attachment.fileExtension) #foreach($doNotDownload in $disabledDownloads) #if($attachmentExtension == $doNotDownload) #set($disabled = true) #break #end #end #if(!$disabled) <a class="filename" href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")" title="$generalUtil.htmlEncodeAndReplaceSpaces($attachment.fileName)" >$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35))</a> #else $generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35)) #end Again, to specify which files you want disabled, change the 'ext1', 'ext2' in the first line to the extensions for which you want to disable downloading. You can specify as many extensions as you want, as long as they are in quotes, are comma separated and do not include the '.' at the start. For example, if I did not want users to download .jpg and .doc and .png files, the line would read #set($disabledDownloads = ['jpg', 'doc', 'png']) Removing the 'Download All' button
Delete or comment the following lines in viewattachments.vm #if ($action.latestVersionsOfAttachments.size() > 1) <a id="download-all-link" class="dashboard-action dashboard-action-text dashboard-action-spacing" href="$req.contextPath/pages/downloadallattachments.action?pageId=$pageId" title="$action.getText('download.all.desc')">$action.getText('download.all')</a> #end |
![]() |
Document generated by Confluence on Jul 09, 2010 01:11 |