mercredi 21 juillet 2021

How to handle image uploading + optimization

I have a feature where a user can create a post and upload up to 10 images. Once these images are uploaded, I want to optimize them before making the post public (i.e. it should remain private until the the job to optimize the images finishes running).

How should I handle this?

My current thinking is:

  • User uploads 10 images and submits the post
  • I insert a new row for each image into the database in a table called temp_post_images
  • The images are stored in a temp folder until they are processed by the job
  • The job gets all rows from temp_post_images for that post, loops through each and optimizes each image
  • Once all images are optimized, it moves the entire temp folder into a permanent folder, and all rows in temp_post_images are moved to the permanent post_images table

However, this seems needlessly complicated and prone to errors.

What would a better solution be here?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire