Create a sandbox project
Create a similar project structure:
The pets.yaml is defined here: https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/yaml/petstore.yaml
The fileResponse message flow is defined as follows:
Define ESQL and Java code
This step defines the relevant code. Note that the whitespace may be collapsed, depending on the current Recipes framework version.
The resourceTypeFolder variable value depends on how Integration Bus / App Connect interprests the file. There are many possible values; to find which one, simply deploy the project and then search the file name on disk. For example, on Windows, pets.yaml can be found here:
The entire path is constructed below in the ReadFile.java.
Deploy and test
Simply deploy the project to a server, open a browser or SoapUI and invoke the following URL: http://<host>:<port>/SandboxWorkspaceFileResponse
The browser should return the file specified in the flow variables. Note that while it may be possible to serve files specified by a request parameter, constraints should be placed on possible file names, for security. The described pattern is applicable to small files which won’t cause out of memory problems due to large object allocation failures. Small file responses can also be cached.
Author: Aleksander Kovač
Thanks to Matthew SeGall from IBM Integration Bus / IBM App Connect support team for explaining how to construct the file path of a deployed BAR file.