Handling Asynchronous Image Saving Before sending images via API for Validation in Backend Workflow

Hello, Bubble Community,

I’m encountering a challenge with managing image uploads and then saving them one by one in my DB and then sending them for validation in an API call in my application and would appreciate any guidance or solutions you might have.

Workflow Description:

  1. Image Collection: In my app, users upload 5 to 8 images as part of a task. These images are then associated with a specific task in a database field.
  2. Scheduled Workflow: Once images are uploaded, I have a scheduled backend workflow that iterates through these images to save them individually in a separate Image table. This table tracks each image’s url, a validity status (yes/no), and an error text field.
  3. External API Validation: After all images for a task are saved, I intend to send them to an external API to validate each image’s content.

Issue Encountered:

The challenge arises due to the asynchronous nature of image saving. Image saving times vary (ranging from 3 to 10 seconds each), and since this process is asynchronous, the API call meant to validate these images sometimes occurs before some or all images have been saved. This results in the API not finding the expected images for the task, as they haven’t been saved in the system yet.

Current Setup Details:

  • I’ve structured the workflow to save and then validate images asynchronously, aiming to enhance efficiency.
  • The workflow checks for IMAGES (images table) associated with the task to send to validation API but often proceeds without them due to the described timing issue.

Seeking Suggestions On:

  • Strategies to ensure all images are fully saved before the validation API call is made.
  • Any workflow adjustments or Bubble.io features that might help synchronize these operations or better manage the timing issue.

Additional Context:

I’ve also attached a screenshot of my current workflow setup for reference. Also, as you can see I have used a plugin to add delay but sometimes even 10 secs is not enough and I think that it would be best if I have a better alternative for this.

I’m looking for advice on how to either adjust my approach to saving and validating images or how to effectively manage the asynchronous nature of these tasks to ensure all images are ready for API validation when needed.

Thank you in advance for your help and insights
Also, Find attached the workflow to save an image which is used in the above workflow.

Not a direct answer but a pointer to a possible direction. Most dropzone type plugins (scan around as there are many eg The Almighty Dropzone) have a feature of emitting a Bubble event along the lines of “all files have completed uploading” and publish states of the files that succeeded and those that failed. The ones I know of are for uploading to external storage providers - but Bubble is not a lot different (other than cost!) to external storage providers.

This is the only way I know of getting an asynchronous event notification that files have completed uploading. Techniques like waiting a period of time, polling the DB etc are never going to reliably work.

Thanks. Even the plugin I am using right now does provide an event for each individual image but this would not be very helpful for me as I am first saving these images against a list field of my task and then using the url of each image to save into another table called IMAGE. Since this is saved as a “thing” in bubble, I would be needing this callback from Bubble DB and not from the plugin. I hope I was clear with this.

You will likely need to re-think your approach rather than try to make Bubble work the way you think it ought to :slight_smile:

I think this video explaining order of operations and how Bubble already attempts to “enhance efficiency” will give you the clue of how to chain workflow actions together synchonously.

Hey there,

Yep just use a database trigger?

When the image field state changes to not empty, trigger the next workflow :slightly_smiling_face: