Mega Code Archive

 
Categories / Ruby / Network
 

Create a temporary file with Tempfile and upload from that

require 'net/ftp' require 'tempfile' tempfile = Tempfile.new('test') my_data = "This is some text data I want to upload via FTP." tempfile.puts my_data ftp = Net::FTP.new('ftp.domain.com') ftp.passive = true ftp.login ftp.chdir('/your/folder/name/here') ftp.puttextfile(tempfile.path, 'my_data') ftp.close tempfile.close