Currently we have a method that returns a string with a formatted CSV file.
string = EXPORT.tickets
We need to upload this csv file to a ftp server like so
ftp = Net::FTP.new(server, username, password)
ftp.putbinaryfile(string)
however, the string
variable is obviously a string, and not a binary file as the putbinaryfile method expects. I see two ways to do this,
- convert the
string
variable to a file first usingFile
- convert the string directly to a file with something like
StringIO
Do these seem like viable options? If so, how would I approach doing this, thanks in advance!
EDIT:
Since the putbinaryfile method is looking for a file path rather than an actual file, it looks like my best best will be to create a File from the string
variable. Can anyone give an example of how this can be accomplished?