Description: Sample Groovy Script to restrict specific file types from being uploaded to the Asite platform.
Context: Document
Document Type: File
Remark: Supported in 'Pre' Mode Only.
Script:
def execute(){
/********** Configurable Parameter Section ************/
String fileExtToBeRestricted = "EXE"; // This is case insensitive. You can add multiple extensions as well. Just add pipe | sign in between two extension like "EXE|ZIP|CPP"
/********** Configurable Parameter Section ************/
DocumentVO document = documentService.getDocumentDetails();
String fileExt = document.getFileName().substring(document.getFileName().lastIndexOf(".")+1);
if (fileExt.matches(("(?i)"+ fileExtToBeRestricted))) {
document.setResponseStatus(false);
document.setResponseMessage(fileExt + " file is not allowed to upload.");
}
return document;
}