rust-postgres/rust-postgres

Is there a way to stream a large-ish `bytea` to the database?

Closed this issue · 2 comments

lvella commented

It seems that BinaryCopyInWriter only works for full rows, but I would like to a single bytea field into the database as it is received from the network. Is this possible?

There's no way to do that with the built-in BinaryCopyInWriter. You could make a custom writer that would be able to do that (you do need to know the size of the buffer and the overall row up-front). IIRC Postgres will buffer the entire row in memory though regardless.

Depending how big these values are, you may want to consider using the large value API, which allows "real" streaming to and from the backend.

lvella commented

Thanks. I found your crate postgres_large_object.