@classmethod
    def download_file(cls, uri, fobj):
        """
        Given a URI, download the file to the ``fobj`` file-like object.

        :param str uri: The URI of a file to download.
        :param file fobj: A file-like object to download the file to.
        :rtype: file
        :returns: A file handle to the downloaded file.
        """
        # Breaks the URI into usable componenents.
        values = get_values_from_media_uri(uri)

        conn = cls._get_aws_s3_connection(values['username'],
                                          values['password'])
        bucket = conn.get_bucket(values['host'])
        key = bucket.get_key(values['path'])

        logger.debug("S3Backend.download_file(): " \
                     "Downloading: %s" % uri)

        try:
            key.get_contents_to_file(fobj)
        except __HOLE__:
            # Raised by ResumableDownloadHandler in boto when the given S3
            # key can't be found.
            message = "The specified input file cannot be found."
            raise InfileNotFoundException(message)

        logger.debug("S3Backend.download_file(): " \
                     "Download of %s completed." % uri)
        return fobj
dataset/ETHPy150Open duointeractive/media-nommer/media_nommer/core/storage_backends/s3.py/S3Backend.download_file