How to create a tiered directory structure in Jitterbit App Builder
By default Amazon's S3 bucket has a flat hierarchy directory structure. This can limit an App Builder application developer when attempting to create folders and directories, however, there is a work-around in App Builder described here using CRUD Rules that allow you to to mimic the tiered hierarchy of a traditional folder structure.
Note
For more information on Amazon's S3 Bucket flat directoy structure, see: https://docs.aws.amazon.com/AmazonS3/latest/user-guide/using-folders.html
Workaround configuration in App Builder
-
Parameterize the
S3OutgoingDataSourceID
- Create a new Column on the Parameter table, named S3OutgoingDataSourceID
- Expose/make configurable from UI in the Configuration menu
- Specify the DataSourceID. To obtain the DataSourceID, navigate to the S3 Data Source in the Data Storage Layer, click the pop-up icon and here you are looking at the resultant URL, specifically for the part that starts with 'DataSourceID' and ending before the '&' character.
-
Create a CRUD Rule to Cram from {{nm.ab}} --> Amazon S3
-
New CRUD, Cram rule
- File (Cram) (S3 Bucket - Cram Directory {{…}} Folder)
-
CRUD setup for Rule:
- Purpose: XP CRUD
- Action: Cram
- Source Data Source: (YourApplicationDataSource)
- Target Data Source: Name of your S3 Data Source. For example: S3 Outgoing
- Logic Layer: selected
- Target: File
-
Register the CRUD Rule to the Save Event
-
Define the mvSQL logic for the Rule, with the following Columns configured:
- Index 10: S3OutgoingDataSourceID targets the DataSourceID
- Index 20: For the directory, use a String value.. This will become the parent of the subfolders
-
Index 30: To create a hierarchy, use the 'Backslash' character ('\') (with no Target specified)
- This can be done by using the ${char(92)}
- Set Logical Data type = String
-
Index 40: A concatenated string; for example:
'Financial Statements' || {{Backslash}} || FST.FinancialStatementName'
- The 'FST.FinancialStatementName' becomes the subfolder under the 'Financial Statement' parent folder
- Set Logical Data type = String
-
Index50: This is a boolean that declares the folder as a directory
- Set this boolean to 1 if you plan on creating a folder-like structure
- Set this boolean to 0 if you do not need subfolders in your bucket
- Set Logical Data type = Boolean
-
-
Run the Results of the CRUD Rule, and confirm there are no errors
-
Run the Results of the 'File' table, after Cram Rule