I have a site with a lot of images uploaded via the image content field. I am switching over to the media module and have successfully imported all the files to show in the media browser. I am now trying to add the correct media to the correct node en mass.

My nodes have an unlimited number of images on them, and I can pull nid, fid, and delta from the database. How do I use this information to bulk associate media with the node? I have tried to reverse engineer the media module to figure this out, but I cannot figure out how the data is saved. I can create rows in the database directly, but that doesn't record file usage correctly.