Upload images to post/page gallery dynamically

Hello all!

I was wondering if anyone can point me in the right direction. Does Wordpress have any built in functions, hooks, filters, etc., to dynamically attach images to a post or page, but as a gallery?

I have all of the separate components I need to start building a really functional front-end image uploader that allows a person to choose images from various places (Facebook, Instagram, etc.).

I would like to make this as light weight as possible, which gave me the idea of using the built in Wordpress gallery functionality. I want to code my uploader to attach the files to a specific page/post and automatically place them in as a gallery attachment.

Is this possible? I am so close!