Complete switching from saving to file to upload to mongoDB