VMware Aria

 View Only
  • 1.  upload File item in service broker : how to use it

    Posted Oct 08, 2023 10:54 PM

    Hello Everyone, 

    I have a use case where i want to add upload file item in custom form of a blueprint in service broker, to let the user attach a file that can be read by an approver to know the detail of the provisioning. how i can get the content of the file and decode it and attach it a PDF or a any format possible. any ideas ?

    Thank You.



  • 2.  RE: upload File item in service broker : how to use it

    Posted Oct 12, 2023 09:32 PM

     

    Hello Arar,
    you can find an approach to handle this with an input form of a workflow in the following post:

    https://communities.vmware.com/t5/VMware-Aria-Automation/FileUpload-Parameter-in-vRO-8-1/td-p/2287347

    Here a guide to add these input forms to the service broker catalog:

    https://docs.vmware.com/en/vRealize-Automation/8.11/Using-and-Managing-Service-Broker/GUID-416D6130-96AD-4912-9AD2-D52CE30CAA31.html

    Best regards
    Stefan



  • 3.  RE: upload File item in service broker : how to use it

    Posted Oct 12, 2023 10:41 PM
      |   view attached

       Thank you for your answer.

     

    Attachment(s)

    txt
    Base64.txt   2 KB 1 version


  • 4.  RE: upload File item in service broker : how to use it

    Posted Oct 13, 2023 06:43 AM

     

    Hello Arar,

    here an example to store the file in the temporary directory:

    1. Define in Inputs/Outputs an input variable, in our case in_file.

    StefanSchnell_0-1697178478004.png

    2. Add in the workflow a scriptable task and assign as input to this in_file. In this case I didn't rename the variable.

    StefanSchnell_1-1697178607796.png

    3. Following lines of code as an example to save any file in the temporary directory.

    StefanSchnell_2-1697178856797.png

    The function saveFileContent saves, with the method write, from the mime parameter, the file in the temporary directory. The lines above checks if a file with the same name exists and if the file exists it will be deleted.

    The function fileExists checks if a file with a specific name exists in the temporary directory and if it exists a message is displayed.

    // Begin----------------------------------------------------------------
    
    function saveFileContent(mime) {
      var file = new File(System.getTempDirectory() + "/" + mime.name);
      if (file.exists) {
        file.deleteFile();
      }
      mime.write(System.getTempDirectory(), null);
    }
    
    function fileExists(fileName) {
      var file = new File(System.getTempDirectory() + "/" + fileName);
      if (file.exists) {
        System.log("File " + fileName + " exists");
      }  
    }
    
    saveFileContent(in_file);
    fileExists(in_file.name);
    
    // End------------------------------------------------------------------

    4. Result

    StefanSchnell_3-1697179258752.png

    StefanSchnell_4-1697179295978.png

    Any file should be able to be saved this way.

    Best regards
    Stefan

     

     

     

     

     

     



  • 5.  RE: upload File item in service broker : how to use it

    Posted Nov 05, 2025 04:21 AM

    Hi Stefan,

    Based on the example you shared, I have a few questions:
    When the workflow runs, how is the MimeAttachment specified in the in_input loaded before calling write()? Is it stored in memory or in a temporary directory on the orchestrator appliance? Once the workflow completes, is the MimeAttachment automatically removed?

    Additionally, is there a control mechanism within the "File Update" process to validate the type of file being uploaded and to enforce a maximum file size limit?

    Regards.

    -------------------------------------------



  • 6.  RE: upload File item in service broker : how to use it

    Broadcom Employee
    Posted Jan 04, 2026 02:03 PM

    I have created a solution for this in TypeScript using the Aria Build Tools

    https://github.com/vmware/build-tools-for-vmware-aria

        public FileSave(objMimeAttachment: MimeAttachment): boolean {
    
            let objFile: File = this.FileGet(objMimeAttachment.name);
    
            let blnResultDelete: boolean = this.FileDelete(objMimeAttachment.name);
    
            if (blnResultDelete === true) {
                let blnResultWrite: boolean = this.FileWrite(objMimeAttachment);
    
                if (blnResultWrite === false) {
                    return false;
                }
                else {
                    return true;
                }
            }
            else {
                return false;
            }
        }
    
        public FileCanWrite(objMimeAttachment: MimeAttachment): boolean {
    
            let objFile: File = this.FileGet(objMimeAttachment.name);
    
            return objFile.canWrite();
        }
    
        public FileCanRead(objMimeAttachment: MimeAttachment): boolean {
    
            let objFile: File = this.FileGet(objMimeAttachment.name);
    
            return objFile.canRead();
        }
    
        public FileWrite(objMimeAttachment: MimeAttachment): boolean {
    
            let strTempDirectory: string = System.getTempDirectory();
    
            try {
                objMimeAttachment.write(strTempDirectory, null);
    
                return true;
            }
            catch {
                return false;
            }
        }
    
        public FileDelete(strFileName: string): boolean {
    
            let objFile: File = this.FileGet(strFileName);
    
            if (objFile.exists) {
                try {
                    objFile.deleteFile();
    
                    return true;
                }
                catch {
                    return false;
                }
            }
        }
    
        public FileExists(strFileName: string): boolean {
    
            let objFile: File = this.FileGet(strFileName);
    
            if (objFile.exists) {
                this.objLogger.info(`File ${strFileName} already exists.`);
            }
    
            return objFile.exists;
        }
    
    
        public FileGet(strFileName: string): File {
    
            let strTempDirectory: string = System.getTempDirectory();
    
            let objFile: File = new File(strTempDirectory + "/" + strFileName);
    
            if (objFile.exists) {
                return objFile;
            }
            else {
                return null;
            }
        }


    ------------------------------
    Simon Sparks
    Automation & Orchestration Consultant
    North West England, UK, Europe
    Broadcom Employee
    ------------------------------