Upload resources immediately instead of on form submit


Dec 21, 2023

DRAFT

[Ivan, Andrew, Max]

Context and Problem Statement

We need a mechanism for uploading resources to cloud storage along with other related data as part of forms.

Considered Options

  • Upload the resource to cloud storage on form submit
  • Upload the resource to cloud storage as soon as it is selected

In both options we use dynamic naming, the resource name would be suffixed with the current timestamp so that we don't replace the previously submitted resource. With dynamic naming in option 1 we avoid replacing the resource in case the form submit fails. With dynamic naming in option 2 we avoid replacing the resource when user chooses different resource and does not actually press save.

Decision Outcome

Chosen option: "[Upload the resource to cloud storage as soon as it is selected]", because it has superior user experience.

Pros and Cons of the Options

[Upload the resource to cloud storage on form submit]

Once user selects an resource, it just gets stored locally in the form state, still not uploaded to cloud storage.

When user presses submit, we upload the resource to storage and then send the resource reference in the form values to the server mutation. Firing the two actions at once (uploading resource and form submit) was not considered here because of the potential inconsistency and recovery needed in case one of the operations fail and the other succeeds.

[Upload the resource to cloud storage as soon as it is selected]

As soon as the user selects the resource, we immediately upload it to cloud storage, and store the received ref as the form value. The ref is then used in the mutation to update the server.