AnyEve...ransfer(3pm)

πŸ“¦ version 0.20, in ubuntu stonking

πŸ’– 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 🫢)

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