If you’re transferring files over a socket (like through SMB or SFTP), the receiving end usually has a small buffer, like 64KB. It’ll just pause the stream if it’s receiving data faster than it can push it to disk and the buffer gets full. So usually a file transfer won’t use much memory.
There is some poorly written software that doesn’t do that, though. I ran into a WebDAV server that didn’t do that when I was writing my own server. That’s where you could run into out of memory errors.