Module: FileTransfer
- Defined in:
- lib/file_transfer.rb,
lib/file_transfer/ftp.rb,
lib/file_transfer/ftps.rb,
lib/file_transfer/sftp.rb,
lib/file_transfer/generic.rb,
lib/file_transfer/version.rb,
lib/file_transfer/file_transfer_handler.rb
Overview
:nodoc:
Defined Under Namespace
Classes: FileTransferHandler, Ftp, Ftps, Generic, Sftp
Constant Summary collapse
- VERSION =
:nodoc:
"0.0.1"
Class Method Summary collapse
-
.download(type, options, paths) ⇒ Object
FileTransfer.download :ftp, {:username => 'foo', :password => 'bar', :host => 'localhost'}, [ {:from => "/remote/uploads/a_1.txt", :to => "/local/1.txt"}, {:from => "/remote/uploads/pdf/*.pdf", :to => "/local/pdf/"}, {:from => ["/remote/uploads/a_1.txt", "/remote/uploads/a_2.txt", "/remote/uploads/txt/*.txt"], :to => "/local/txt/"} ]. - .exists?(type, options, path) ⇒ Boolean
-
.upload(type, options, paths) ⇒ Object
Uploads one or more files to a remote server.
Class Method Details
.download(type, options, paths) ⇒ Object
<tt>FileTransfer.download :ftp,
{:username => 'foo', :password => 'bar', :host => 'localhost'}, [
{:from => "/remote/uploads/a_1.txt", :to => "/local/1.txt"},
{:from => "/remote/uploads/pdf/*.pdf", :to => "/local/pdf/"},
{:from => ["/remote/uploads/a_1.txt", "/remote/uploads/a_2.txt", "/remote/uploads/txt/*.txt"], :to => "/local/txt/"}
]
</tt>
59 60 61 62 63 |
# File 'lib/file_transfer.rb', line 59 def self.download(type, , paths) handler = FileTransferHandler.new type, handler.download paths handler.close end |
.exists?(type, options, path) ⇒ Boolean
65 66 67 68 69 |
# File 'lib/file_transfer.rb', line 65 def self.exists?(type, , path) handler = FileTransferHandler.new type, handler.exists? path handler.close end |
.upload(type, options, paths) ⇒ Object
Uploads one or more files to a remote server. To upload files use the locale file paths, not the ruby class File. Types are:
-
:ftp- for FTP file upload -
:ftps- for FTPS file upload -
:sftp- for SFTP file upload
Options are:
-
:username- Specifies the username for login to the remote server -
:password- Specifies the password for login to the remote server -
:host- Specifies the name of the remote server. It could be a DNS name or an IP-Address these options are not necessary. -
:port- Specifies the port of the remote server. If the remote server listen on the default port, -
:timeout- If connection hangs, it is possible to define a timeout in seconds here, where the connection will be automatically closed.
Examples
<tt>FileTransfer.upload :ftp,
{:username => 'foo', :password => 'bar', :host => 'localhost'}, [
{:from => "/local/1.txt", :to => "/remote/uploads/a_1.txt"},
{:from => "/local/", :to => "/remote/uploads/"},
{:from => "/local/pdf/*.pdf", :to => "/remote/uploads/pdf/"},
{:from => ["/local/1.txt", "/local/2.txt", "/local/txt/*.txt"], :to => "/remote/uploads/txt/"}
]
</tt>
45 46 47 48 49 |
# File 'lib/file_transfer.rb', line 45 def self.upload(type, , paths) handler = FileTransferHandler.new type, handler.upload paths handler.close end |