def download(self, url,<EOL>file_name,<EOL>headers=None,<EOL>show_progress=True):
tmp_file = get_tmpfile(prefix="<STR_LIT>" % file_name)<EOL>verify = self._verify()<EOL>if requests.head(url, verify=verify).status_code in [<NUM_LIT:200>, <NUM_LIT>]:<EOL><INDENT>response = self.stream(url,<EOL>headers=headers,<EOL>stream_to=tmp_file,<EOL>show_progress=show_progress)<EOL>if isinstance(response, HTTPError):<EOL><INDENT>bot.error("<STR_LIT>" %url)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>shutil.move(tmp_file, file_name)<EOL><DEDENT>else:<EOL><INDENT>bot.error("<STR_LIT>" %url)<EOL><DEDENT>return file_name<EOL>
stream to a temporary file, rename on successful completion

        Parameters
        ==========
        file_name: the file name to stream to
        url: the url to stream from
        headers: additional headers to add
        force: If the final image exists, don't overwrite
        show_progress: boolean to show progress bar