BUG: release upload file memory after using

After storing the file (successful or unsuccessful), close the upload file object.