Skip to main content
Version: Previous

Document Management - `endpoints

Document Management exposes upload, download and list file endpoints. Endpoints are registered automatically on start-up.

File upload

To upload a file, send a multiform POST request to the following resource path: /file-server/upload.

To construct a multiform POST request, you must provide a key for the form data, and a value (the file content). The headers must also be set correctly:

Content-Type : multipart/form-data
Content-Disposition : filename=<filename>

If you are using an HTTP testing tool like Postman, it should set these header values for you.

File download

To download a file, send a GET request to the following resource path with the following query param /file-server/download?fileStorageId=<fileStorageId>.

List all files

To list all files, send a GET request to /file-server/all-files.

Linking assets

To link assets (css, image files etc...), you need to define an eventHandler codeblock. This must insert one or more objects into the TemplateAsset table. Use the following as an example.

    data class LinkTemplateAssets(
val templateId: String,
val assetIds: List<String>
)

eventHandler<LinkTemplateAssets>(name = "LINK_TEMPLATE_ASSETS") {
onCommit { event ->
val details = event.details

val templateAssets = details.assetIds.map {
TemplateAsset {
templateId = details.templateId
assetId = it
}
}

entityDb.insertAll(templateAssets)
ack()
}
}

Once your event handler is registered, and you have uploaded both the template and asset file(s), you can send a POST request to EVENT_LINK_TEMPLATE_ASSETS with the following request body

{
"MESSAGE_TYPE": "EVENT_LINK_TEMPLATE_ASSETS",
"USER_NAME": "<USER_NAME>",
"DETAILS": {
"TEMPLATE_ID": "<templateId>",
"ASSET_IDS": ["assetId","assetId"]
}
}