def download_file(self, remoteFileName, localFilePath=None, connId='<STR_LIT:default>'):
thisConn = self.__getConnection(connId)<EOL>outputMsg = "<STR_LIT>"<EOL>localPath = "<STR_LIT>"<EOL>if localFilePath == None:<EOL><INDENT>localPath = remoteFileName<EOL><DEDENT>else:<EOL><INDENT>localPath = os.path.normpath(localFilePath)<EOL>if os.path.isdir(localPath):<EOL><INDENT>localPath = os.path.join(localPath, remoteFileName)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>with open(localPath, '<STR_LIT:wb>') as localFile:<EOL><INDENT>outputMsg += thisConn.retrbinary("<STR_LIT>" + remoteFileName, localFile.write)<EOL><DEDENT><DEDENT>except ftplib.all_errors as e:<EOL><INDENT>raise FtpLibraryError(str(e))<EOL><DEDENT>if self.printOutput:<EOL><INDENT>logger.info(outputMsg)<EOL><DEDENT>return outputMsg<EOL>
Downloads file from current directory on FTP server in binary mode. If
localFilePath is not given, file is saved in current local directory (by
default folder containing robot framework project file) with the same name
as source file. Returns server output
Parameters:
- remoteFileName - file name on FTP server
- localFilePath (optional) - local file name or path where remote file should be saved.
- connId(optional) - connection identifier. By default equals 'default'
localFilePath variable can have following meanings:
1. file name (will be saved in current default directory);
2. full path (dir + file name)
3. dir path (original file name will be added)
Examples:
| download file | a.txt |  |  |
| download file | a.txt | b.txt | connId=ftp1 |
| download file | a.txt | D:/rfftppy/tmp |  |
| download file | a.txt | D:/rfftppy/tmp/b.txt |  |
| download file | a.txt | D:\\rfftppy\\tmp\\c.txt |  |