Modify uploads to deal with mimetypes and better json writing