Fix bug upload middleware