Handling Image Upload Inconsistencies in Draft Forms

In the app, every page has a “Continue” or “Proceed” button that triggers an API call to save the form data to the database. However, there’s an issue when the page has an image capture field.

For example, if I click a photo using the camera task and tap the tick button to confirm the image, the image gets uploaded to the server immediately. But if I don’t press the “Save” button on that page and kill the app, the form data isn’t saved.

Later, when I reopen the app from the drafts, the data on that page is empty because the “Save” button wasn’t pressed earlier. But the image is already on the server. Still, the app shows 0 uploaded images, because the local path (or reference to the uploaded image) wasn’t saved locally.

This causes a mismatch: the image exists on the server, but it’s not linked to the draft.

What is the best way to handle this kind of inconsistency? Is there a better approach to prevent such issues?

2 Likes

Your question already contains the answer.

Whenever you upload an image using either the “Upload Media” or “Camera” task, you need to ensure that the associated entity data is also saved to the server to maintain consistency.

However, if in your scenario you only want to save data to the server when the “Save” button is clicked, then you should trigger the media upload only at that point—not during the camera task. In the Camera task, there’s an option to disable the “Upload Media” feature. Simply uncheck it to prevent automatic uploads.

3 Likes