Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Restrict specific file types to be uploaded in Asite platform
Groovy Script - Restrict specific file types to be uploaded in Asite platform
Updated this week

Description: Sample groovy script to restrict specific file types to be uploaded in Asite platform.

Context: Document

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;

}



Did this answer your question?