Solving the problem of multiple writes to the database
I have a form which allows people to upload images. When a user uploads an image, I save to a database, 1) a modified name for the image, 2) a caption for the image, 3) the id of the user who uploaded the image, 4) Some other information that are used for image retrieval purposes
The form allows users to upload up to 30 images. I do not want to write to the database each time the user wants to upload an image. Rather, I want to store each upload request (plus all the associated information I need like captions etc) and make a large write when a user has confirmed that he/she is satisfied with all of their choices.
How can I do this easily? 1) I have considered storing the attributes and information associated with each image in cookies and retrieving and processing cookie information after the user has confirmed his/her choices. However, I am not comfortable with this option as I cannot control what happens to the cookies when they are stored in the client machine.
2) Another option is to obtain many hidden fields (more than 30) in the HTML form and fill these up with the associated information I need. I could then process the information in these hidden fields before writing to the database. However, this seems pretty clumsy.
3) A third option I was considering was using Amazon's Simple Queue Service to queue image upload requests and then unqueue and process the messages after a user finished making his/her choices and hit a confirm button.
Which solution among these 3 is the cleanest and most flexible implementation? Are there other solutions for this problem?
Thanks all.