Download support

Download now works. Files are written to and read from the database.