I have a process that fetches a flat file from a mainframe via FTP. This usually works fine for some files. In others, I get: Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8
That's using Net::FTP's
gettextfile
method.
Here is my code:
def find_file( position, value ) # => Value = CLKDRP03.txt, Forget the variable Position
ftp = Net::FTP.new('IP') # => status 200
ftp.login('user','pass') # => True
files = ftp.list('*' + value + '*') # => Obtain the file
if files[0] != nil
str_file = files[0].split(" ").last # => Obtain the name of the file. In this case CLKDRP03.txt
ftp.gettextfile(str_file,'data/input/' + str_file) # => ERROR!, str_file = CLKDRP03.txt
# => data/input is the path where I put the files from FTP.
return str_file
else
return false
end
end
If I comment the line of ftp.gettextfile
, the error keeps coming.
Thanks in advance! Sorry for my english.