caluma
caluma copied to clipboard
Handle failed or omitted file uploads
When saving a FileAnswer
, Caluma assumes that the file is uploaded to the bucket afterwards. There are cases where this doesn't happen and Caluma has data about a file that doesn't exist in the bucket. For example, when the upload to MinIO fails for some reason, the browser crashes or something similar.
We want to know when a file is not uploaded, and treat FileAnswer
s without actual file as potentially equal to non-existing.
Proposal
In Alexandria we let MinIO call an endpoint on our side after completed uploads. There we use it to generate Thumbnails (https://github.com/projectcaluma/alexandria/blob/main/alexandria/core/views.py#L144). The same mechanism could be used in Caluma to know if a file really was uploaded.
Process
The process would look like this:
- Client saves
FileAnswer
in Caluma - Caluma saves the
File
and marks it as "draft" - Client uploads file to the bucket
- MinIO send a request to Caluma, informing about the newly uploaded file
- Caluma unmarks the
File
as draft.
Caluma then could treat draft Files
as non-existent and also ignore the corresponding FileAnswer
.
Implementation suggestion
- Add
draft
flag toFile
model - Add
draft
flag to GQL schema, so frontend can treat it accordingly - Add webhook to mark a file as "successfully uploaded"
- Extend documentation