AnyEve...ransfer(3pm)
π NAME π
AnyEvent::FTP::Client::Transfer β bestie, this is the transfer class for the asynchronous ftp client π like it's literally the object that babysits one file transfer for you
β¨ VERSION β¨
version 0.20 π (yes she's vintage, she's still serving)
πΈ SYNOPSIS πΈ
okay so watch this:
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);
});
look at that. two transfers. one upload, one download. no cap. π₯
π¦ DESCRIPTION π¦
So. This class? It represents a file transfer with a remote server. That's the whole vibe. π
Transfers may be initiated between a remote file name and a local object. And your local object can be a regular scalar, a reference to a scalar, or a file handle β for the deets on all that, go look at the "stor", "stou", "appe" and "retr" methods in AnyEvent::FTP::Client. iykyk π
Real talk though: this documentation is about what you can do with the transfer object once it has already been initiated. Like, the transfer's already happening, bestie, now what π«Ά
π ROLES π
This class consumes these roles (she's got range, obviously):
AnyEvent::FTP::Role::Event
π EVENTS π
This class provides these events β three of them, cute little trio:
π open
Emitted when the data connection is opened π« and it 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
});
that's your moment. the connection's live. go off β¨
π close
Emitted when the transfer is complete β and by complete I mean either because it successfully transferred or because the server returned a failure status π (she doesn't judge, both count). 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. that's it. that's the whole event. bye π
$xfer->on_eof(sub {
# no args passed in
});
not me noticing she passes in literally nothing. iconic.
π 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. so if you already know that one, you already know this one π«Ά
β ready
Returns true if the transfer has completed (either successfully or not π). And if it's true, then it is safe to call "recv" to retrieve the response β because some event loops do not support calling "recv" before there is a message waiting π so like, vibe check first, then recv. periodt.
π₯ recv
Retrieve the AnyEvent::FTP::Client::Response object. that's the tea. that's the response. go get her π
π remote_name
For "STOU" transfers ONLY β this returns the remote file name. only STOU. i repeat, STOU only. everyone else sit down π
π AUTHOR π
Author: Graham Ollis <plicease@cpan.org>
Contributors:
- Ryo Okamoto
- Shlomi Fish
- JosΓ© JoaquΓn Atria
(three whole contributors. a little collab. we love to see it π«Ά)
πΈ COPYRIGHT AND LICENSE πΈ
This software is copyright (c) 2017-2022 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. π free as in freedom, bestie.
okay that's the whole page, you ate that π this was the AnyEve...ransfer(3pm) page out of the User Contributed Perl Documentation (perl v5.40.1, dated 2026-02-16) β mwah, go write some transfers, you've got this π¦β¨π
π¦ where this page comes from
- ubuntu stonking: libanyevent-ftp-perl 0.20-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms