If anyone in the future still has this problem, PostgreSQL provides lo_manage for this purpose: https://www.postgresql.org/docs/9.0/static/lo.html