change middleware to write file in the DOM instead of linking to them