Send content to owner of gpg public key, nested content symmetric encryption
If you encrypt a text file with the GPG utility, it randomly chooses a symmetric key, encrypts the file using that key, then encrypts the symmetric key using an asymmetric algorithm, and embeds the encrypted symmetric key in the file. There is a format that GPG uses and expects, but it is not easy to work with.

There is an RFC that describes the OpenPGP file format. It's not fun reading, but with a lot of hex dumps and a lot of time with the GPG source, I did figure out the basics of a GPG-encrypted file.

I did take the openssh project and carve out the sftp piece to build a package that encrypts the files when it puts them on the remote server and decrypts them when it reads from the remote server. The format of the files is GPG-compatible, without using the GPG utility. You might find some useful code in there for generating GPG-readable files, mostly in the iron subdirectory. IronCoreLabs/ironssh GitHub project