So, it looks like COPY support will have to be divided into two parts,
/copyto, which is fine.
They are both interesting, in that since the idea is to support scaling, the implementations absolutely must stream, rather than taking files or holding data in memory.
The parts needed are
- The node-postgres add-on for handling streaming COPY, https://github.com/brianc/node-pg-copy-streams
- The node middleware for reading multi-part form data https://github.com/expressjs/multer, so that a POST file upload can be read
- An implementation of a multer custom storage engine to bind the upload stream to the copy stream https://github.com/expressjs/multer/blob/master/StorageEngine.md
The parts do in fact all fit together and work, as can been seen in this small proof-of-concept: