Backport connection_dir_buf_add() to 0.3.4 and later

We need connection_dir_buf_add() in 0.3.4 for #21377 (moved).

But I don't want to backport all the refactoring, just the new function.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information