Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'net/ftp'
- require 'ftools'
- class PdfToFtp < AbstractProcessor
- class << self
- def invoke(args)
- hostname = args[:hostname] || arg_error
- username = args[:username] || arg_error
- password = args[:password] || arg_error
- localpath = args[:localpath] || arg_error
- remotepath = args[:remotepath] || arg_error
- verbose = args[:verbose] || false
- additional_params = args[:params] || false
- node_id = args[:node_id] || arg_error
- Net::FTP.new(hostname,username,password) do |ftp|
- puts "new ftp"
- ftp.login
- puts "login"
- ftp.chdir(remotepath)
- puts "chdir"
- if args[:node_id]
- puts "node_id is defined"
- local_file = File.join(localpath,node_id,"print/book.pdf")
- remote_dir = File.join(remotepath,node_id)
- remote_file = File.join(remote_dir,"book.pdf")
- ftp.mkdir(remote_dir)
- puts "mkdir done"
- ftp.putbinaryfile(local_file,remote_file)
- puts "putbinaryfile done"
- else
- puts "no node_id"
- end
- end
- end
- def about
- super + "Puts generated PDFs on FTP server."
- end
- def usage
- super + "Must supply ftp details."
- end
- end
- end
Add Comment
Please, Sign In to add comment