Skip to content

Instantly share code, notes, and snippets.

@trivektor
Created July 27, 2012 00:00
Show Gist options
  • Select an option

  • Save trivektor/3185314 to your computer and use it in GitHub Desktop.

Select an option

Save trivektor/3185314 to your computer and use it in GitHub Desktop.
FTP a file in Ruby
ftp = Net::FTP.new(server, username, password)
ftp.passive = true
ftp.chdir('some dir')
uploaded_file = params[:file][:file]
ftp.putbinaryfile(uploaded_file.tempfile)
ftp.rename(File.basename(uploaded_file.tempfile.to_path), uploaded_file.original_filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment