Upgraded file upload code to use latest mechanism from HttpClient