projectcaluma/caluma

Handle failed or omitted file uploads

Opened this issue · 0 comments

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 FileAnswers 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:

  1. Client saves FileAnswer in Caluma
  2. Caluma saves the File and marks it as "draft"
  3. Client uploads file to the bucket
  4. MinIO send a request to Caluma, informing about the newly uploaded file
  5. 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 to File model
  • Add draft flag to GQL schema, so frontend can treat it accordingly
  • Add webhook to mark a file as "successfully uploaded"
  • Extend documentation