Files

Frends templates for files. File templates allow to perform common file and directory operations.
This template reads a JSON file from a local fileshare and inserts its contents into a MongoDB collection.
This template assumes that the following prerequisites are in place:
This template inserts each data object into a MongoDB collection as a separate row. The template only handles the insertion of new data, and it does not perform checks for existing rows in the collection.
The path to the file in the local fileshare, as well as the target MongoDB database and collection, are determined within the process variables. If the specified database or collection does not already exist, they will be created automatically.
Example JSON data structure
[
{
"name": "John Doe",
"email": "john.doe@example.com",
"age": 29,
"address": {
"street": "123 Main St",
"city": "Springfield",
"state": "IL",
"zip": "62701"
},
"interests": ["reading", "gaming", "hiking"]
},
{
"name": "Jane Smith",
"email": "jane.smith@example.com",
"age": 34,
"address": {
"street": "456 Elm St",
"city": "Springfield",
"state": "IL",
"zip": "62702"
},
"interests": ["cooking", "traveling", "swimming"]
}
]
If the file cannot be read, the process throws an exception. If inserting a row fails, the process throws an exception. The template does not handle transient errors separately, however the connection to MongoDB is tried 3 times before failing.
InFilePath | The full path of the JSON file, including the file name. |
ConnectionString 🗝 | The connection string for accessing the MongoDB instance. |
Database | The name of the MongoDB database. |
Collection | The name of the MongoDB collection where the file data will be inserted. |