Add support for file upload

Note: This is an early merge (not complete, not tested) of the covariate file upload story, so that the file upload parts of it can be reused in the csv upload story.
Comment explaining what this does? Probably being slow but I can't work it out :)