LiveView Uploads for association within nested form

Has anyone set up LiveView uploads for an association in a nested form? I set up my form very similar to the example in the Dynamically adding and removing inputs section of the inputs_for/1 documentation.

Using that example, I now want to add an avatar for each email that is an image uploaded to S3.

I’m trying to figure out how to call allow_upload/3 for each inputs section that I dynamically add. Then how I would keep track of everything to properly handle the uploads with consume_uploaded_entries/3.

I looked through @mcrumm 's live upload example repo and found examples of multiple file uploads and file uploads using a live component, but didn’t find an example that matched this scenario.

I was wondering if I could include a LiveComponent in each inputs section to handle the file upload for that input and then maybe send the upload data up to the parent?

Does anyone have any tips or tricks for how to approach this?

I‘d suggest splitting up doing uploads from management of uploaded entries. It‘ll be simpler to manage that trying to have an upload for per nested entry. Uploads are already quite complex, adding them dynamically will make it even more complex. As an alternative you could e.g. have the upload field set to to auto upload and adjust the form with the new entry once the upload is in progress or once it‘s done.

Thanks! The auto upload example looks like it could work for me.

I’m going to give that a try and then fall back to splitting them up if I have trouble getting that to work.