claceio / clace

Webapp management for internal tools, app server for containerized apps
https://clace.io
Apache License 2.0
489 stars 9 forks source link

[feature] file params #44

Open Dafaque opened 2 days ago

Dafaque commented 2 days ago

Implement file picking and processing for Action Apps. Picking:

Processing:

For me use case is to create wrappers around some AI cmd's which has no REST. I want to:

akclace commented 2 days ago

Thanks for filing the ticket. I am taking a look at what changes are required for adding file upload/download support for Actions

akclace commented 1 day ago

Added display_type support in param definition, see https://github.com/claceio/clace/blob/fa8a97c5ab6435ee4edbdca14039156f9fd105c6/internal/app/tests/appaction_test.go#L867

For string types, display_type can be FILE/PASSWORD/TEXTAREA. For file, the file is uploaded and saved to a temp directory on the server. args.param_name will reference the temp file name on disk. It can be passed to exec.run to process the file data.

Multiple file type params are supported, each param supports single file upload only. The temp directory is deleted at the end of the action handler function.

Returning output file requires more work. If the run command generates a file on disk, referencing that file name directly will not work when multiple Clace servers are present behind a load balancer (since file will be on one of the machines). The plan is to add a fs.load_file API which will load file from disk to the Clace managed database. The ace.result will return a reference to that uploaded file, so that the API access will work from any machine.