NAME
AnyEvent::FTP::Client::Transfer - Transfer class for asynchronous ftp client
VERSION
version 0.19
SYNOPSIS
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);
});
DESCRIPTION
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.
This documentation covers what you can do with the transfer object once it has been initiated.
ROLES
This class consumes these roles:
EVENTS
This class provides these events:
open
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
});
close
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
});
eof
Emitted when the data connection closes.
$xfer->on_eof(sub {
# no args passed in
});
METHODS
cb
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.
ready
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.
remote_name
For STOU
transfers ONLY, this returns the remote file name.
AUTHOR
Author: Graham Ollis <plicease@cpan.org>
Contributors:
Ryo Okamoto
Shlomi Fish
José Joaquín Atria
COPYRIGHT AND LICENSE
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.