When a user selects multiple files, you may want to save each file separately in Bubble's database. This is achieved through an API Workflow that runs "on a list," allowing each item to be processed individually.
Definition:
An API Workflow (or Backend Workflow) is a workflow that runs on Bubble's server. It can be called from the client side (e.g., using "Schedule API Workflow on a List") to perform operations like creating or modifying data in the database without blocking the user interface.
Accessing Backend Workflows:
Creating a New Endpoint:
Defining Parameters:
Add the following parameters (configuring the correct type for each):
Each parameter will represent a field of the file obtained from the picker.
Configuring the Creation Action:
To execute the API Workflow on each item in a list:
On the Client-Side Workflow:
Selecting the List:
Mapping Parameters:
Suppose the plugin exposes a state called selected_files , which is a list of objects. Each object includes: file_url , file_id , file_size , file_name , file_extension , mime_type , and thumbnail .
Steps:
API Workflow Configuration:
In the Client-Side Workflow:
Data Validation:
Ensure that the data obtained from the picker is valid. Although the plugin incorporates validations, the API Workflow can include additional checks.
Error Handling:
Configure actions in the API Workflow to handle errors, such as notifying the administrator or retrying the operation in case of failure.
Scalability:
Using "Schedule API Workflow on a List" allows processing a large number of files independently on the server, avoiding client-side bottlenecks.
Auditing:
Consider extending the API Workflow to log additional information about each operation, facilitating auditing and troubleshooting.
Testing:
Perform thorough testing to ensure that each file is saved correctly in the database.
Was this page helpful?
Thank you for your feedback!
Please Login First
Comments (00)