File Picker
Overview
With a FilePicker
you can ask users to attach a file within a template. The file won't be stored in witboost, but it can be passed to the actions configured in a template leveraging nunjucks.
For instance, by using this picker, you can attach a file together with an Access Request in a Access Control Request Template and send it to your external microservice using a Remote Request Hook.
Configuration
To add a FilePicker
into your template place the following configuration lines:
# your YAML file containing the template definition
spec:
parameters:
properties:
# other fields configured...
plainFile:
ui:field: FilePicker
title: Attachment
description: Upload a file here
This is how the configured FilePicker
will look like when added into a template:
You can further configure the FilePicker
to handle special needs in terms of accepted files and by limiting the file size that a user can attach:
# your YAML file containing the template definition
spec:
parameters:
properties:
# other fields configured...
document:
ui:field: FilePicker
title: Attach a PDF
accept: .pdf
maxSizeMb: 1
description: Upload your pdf here
Using the accept
property we restricted the allowed file types. Behind the scenes, the accept property is passed as is to an input HTML element. It is up to the client's OS to manage the filtering of the files accordingly. See more here how you can configure the accept
property.
Moreover, the maxSizeMb
is the file size limit, expressed in MB, that you allow users to upload. Even if no limit is specified, be careful not to exceed the maximum payload size limit that is imposed both by witboost backend, that by default is 3MB, and eventually Nginx if it's installed in your infrastructure. This limit can be easily exceeded if you place more than one file picker in your template.
When you setup those two properties, or any of the two, the user will be informed about the allowed files or the maximum file size:
Be careful when allowing big files or setting up more than one FilePicker in your template, since you might experience some HTTP errors when the payload exceeds the maximum allowed size of HTTP payloads in requests. This is very common if you have Nginx in your infrastructure setup. In case it is an issue with Nginx you will need to extend the size limit of payloads.