Skip to content

Instantly share code, notes, and snippets.

@DeTeam
Created May 19, 2009 13:41
Show Gist options
  • Save DeTeam/114100 to your computer and use it in GitHub Desktop.
Save DeTeam/114100 to your computer and use it in GitHub Desktop.
Shoes.app(:title => 'FTP File Uploader', :width => 500, :height => 400, :resizable => false) do
require 'net/ftp'
background gradient rgb(255, 255, 255), rgb(150, 150, 150), :angle => 45
stack :margin => 20 do
caption 'FTP File Uploader'
flow :margin => 3 do
inscription 'FTP-server: '
@server = edit_line :width => 200
end
flow :margin => 3 do
inscription 'FTP-path: '
@path = edit_line :width => 200
end
flow :margin => 3 do
inscription 'Username: '
@username = edit_line :width => 200, :text => 'anonymous'
end
flow :margin => 3 do
inscription 'Password: '
@password = edit_line :width => 200, :secret => true
end
para
flow :margin => 3 do
inscription 'Filename: '
@filename = edit_line :width => 200
para ' '
button 'Browse...' do
@filename.text = ask_open_file
end
end
flow :margin => 3 do
button 'Upload' do
@status.text = ''
begin
Net::FTP.open(@server.text) do |ftp|
ftp.login(@username.text, @password.text)
ftp.chdir(@path.text)
ftp.putbinaryfile(@filename.text)
end
@status.text = 'File transfered'
rescue Exception => e
alert "Error: #{e}"
end
end
end
flow :margin => 3 do
@status = para ''
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment