I have a web application running Flutter 3.27.1. In an interface, I fill in a customer card and then I click on the Add customer button. With the click I save in database but I also have to Create a directory for this client in the web application directory. I provide an interface to list and search pdf files in this directory. Except that I don’t know how to code the creation of a folder or a file via this click of a button. How to do it?
Generally speaking you cannot create a file system directory from a web app. The ultimate answer to this question will depend on the architecture of your application. Is the web app running on a different machine that the service layer? Do you want to create the directory on the machine the web app is running on or the machine the service layer is running on?
I am assuming the later. In that case create an api call that will create the folder from the service layer code. A quick an dirty way to do this would be to tie code into the database save endpoint that does this at the same time if the database save is successful.
To create a directory on a button click in your Flutter web app, you’ll need to handle the folder creation on the server side. You can send a request to your backend (e.g., using HTTP) when the button is clicked, and then use a server-side language (like Node.js, Python, etc.) to create the folder.