Guest User

Untitled

a guest
Mar 4th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. Shoes.app(:title => 'FTP File Uploader', :width => 500, :height => 400, :resizable => false) do
  2.  
  3. require 'net/ftp'
  4.  
  5. background gradient rgb(255, 255, 255), rgb(150, 150, 150), :angle => 45
  6.  
  7. stack :margin => 20 do
  8. caption 'FTP File Uploader'
  9.  
  10. flow :margin => 3 do
  11. inscription 'FTP-server: '
  12. @server = edit_line :width => 200
  13. end
  14.  
  15. flow :margin => 3 do
  16. inscription 'FTP-path: '
  17. @path = edit_line :width => 200
  18. end
  19.  
  20. flow :margin => 3 do
  21. inscription 'Username: '
  22. @username = edit_line :width => 200, :text => 'anonymous'
  23. end
  24.  
  25. flow :margin => 3 do
  26. inscription 'Password: '
  27. @password = edit_line :width => 200, :secret => true
  28. end
  29.  
  30. para
  31.  
  32. flow :margin => 3 do
  33. inscription 'Filename: '
  34. @filename = edit_line :width => 200
  35. para ' '
  36. button 'Browse...' do
  37. @filename.text = ask_open_file
  38. end
  39. end
  40.  
  41. flow :margin => 3 do
  42. button 'Upload' do
  43. @status.text = ''
  44. begin
  45. Net::FTP.open(@server.text) do |ftp|
  46. ftp.login(@username.text, @password.text)
  47. ftp.chdir(@path.text)
  48. ftp.putbinaryfile(@filename.text)
  49. end
  50. @status.text = 'File transfered'
  51. rescue Exception => e
  52. alert "Error: #{e}"
  53. end
  54. end
  55. end
  56.  
  57. flow :margin => 3 do
  58. @status = para ''
  59. end
  60.  
  61. end
  62. end
Add Comment
Please, Sign In to add comment