#NEWLINE# @ classmethod #NEWLINE# def download_file( cls , uri , fobj ) : #NEWLINE# #INDENT# '\n        Given a URI, download the file to the ``fobj`` file-like object.\n\n        :param str uri: The URI of a file to download.\n        :param file fobj: A file-like object to download the file to.\n        :rtype: file\n        :returns: A file handle to the downloaded file.\n        ' #NEWLINE# values = get_values_from_media_uri ( uri ) #NEWLINE# conn = cls . _get_aws_s3_connection ( cls [ 'username' ] , values [ 'password' ] ) #NEWLINE# bucket = conn . get_bucket ( values [ 'host' ] ) #NEWLINE# key = bucket . get_key ( values [ 'path' ] ) #NEWLINE# logger . debug ( ( 'S3Backend.download_file(): Downloading: %s' % uri ) ) #NEWLINE# try : #NEWLINE# #INDENT# key . get_contents_to_file ( fobj ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# message = 'The specified input file cannot be found.' #NEWLINE# raise InfileNotFoundException ( message ) #NEWLINE# #UNINDENT# logger . debug ( ( 'S3Backend.download_file(): Download of %s completed.' % uri ) ) #NEWLINE# return fobj