I’m working on a screen which does the following
- a single user has multiple work items stored in a separate table
- depending on the condition, will render either a single text input, a text input and a file input, or both.
- submits the data to the server and upload the files to Google Cloud Storage
Example payload sent by the frontend:
%{
action_item_id[]: [ %Plug.Upload{}]
action_item_id-input: "test input"
}
The map key corresponds to the row id of the action item.
Here’s what I’ve done so far.
- Loop through
params
entries usingEnum.map
- Create a 3 functions that matches a string map value,
a single Plug.Upload struct or a list of Plug.Upload struct - I’m thinking of performing DB ops and file upload inside the
Enum.map
Seeking advice for the following:
- File validation (checking file extension is okay)
- Check if action_item_id is a valid id or not
- Should I put uploading and database operations near each other
I can already upload a file and the db operation is for updating fields of that particular action item.
If information above are not enough I will gladly put more informstion to it.