AnyEvent::FTP::Client::Transfer - Transfer class for asynchronous ftp client
version 0.19
use AnyEvent::FTP::Client; my $client = AnyEvent::FTP::Client; $client->connect('ftp://ftp.cpan.org')->cb(sub { # $upload_transfer and $download_transfer are instances of # AnyEvent::FTP::Client::Transfer my $upload_transfer = $client->stor('remote_filename.txt', 'content'); my $buffer; my $download_transfer = $client->retr('remote_filename.txt', \$buffer); });
This class represents a file transfer with a remote server. Transfers may be initiated between a remote file name and a local object. The local object may be a regular scalar, reference to a scalar or a file handle, for details, see the stor, stou, appe and retr methods in AnyEvent::FTP::Client.
stor
stou
appe
retr
This documentation covers what you can do with the transfer object once it has been initiated.
This class consumes these roles:
AnyEvent::FTP::Role::Event
This class provides these events:
Emitted when the data connection is opened, and passes in as its first argument the AnyEvent::Handle instance used to transfer the file.
$xfer->on_open(sub { my($handle) = @_; # $handle isa AnyEvent::Handle });
Emitted when the transfer is complete, either due to a successful transfer or the server returned a failure status. Passes in the final AnyEvent::FTP::Client::Response message associated with the transfer.
$xfer->on_close(sub { my($res) = @_; # $res isa AnyEvent::FTP::Client::Response });
Emitted when the data connection closes.
$xfer->on_eof(sub { # no args passed in });
Register a callback with the transfer to be executed when the transfer successfully completes, or fails. Works exactly like the AnyEvent condition variable cb method.
cb
Returns true if the transfer has completed (either successfully or not). If true, then it is safe to call recv to retrieve the response (Some event loops do not support calling recv before there is a message waiting).
recv
Retrieve the AnyEvent::FTP::Client::Response object.
For STOU transfers ONLY, this returns the remote file name.
STOU
Author: Graham Ollis <plicease@cpan.org>
Contributors:
Ryo Okamoto
Shlomi Fish
José Joaquín Atria
This software is copyright (c) 2017-2021 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install AnyEvent::FTP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::FTP
CPAN shell
perl -MCPAN -e shell install AnyEvent::FTP
For more information on module installation, please visit the detailed CPAN module installation guide.