write files and support having a top-level directory for uploaded files