If you want to execute that JavaScript on file upload, then add a rule to the folder you are uploading to, or a parent folder, that executes this script. The script file is put in /Data Dictionary/Scripts. No need to create/configure Spring beans. Make sure also to have a content model deployed with the type custom:dtls available.