Remove files that are not PDF, XLS, DOC, or PNG filetypes after they are uploaded

This script can be used for file type restriction

import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.pages.AttachmentManager
def attachmentManager = ComponentLocator.getComponent(AttachmentManager)
def attachment = event.getAttachment()

if (attachment.getFileExtension() != "pdf"||"xls"||"doc"||"png")
{
attachmentManager.removeAttachmentFromServer(attachment)
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.