thekid/rfc — Issue #142: RFC 0141: FTP Transfer listening
Author: thekid
Created: 2011-10-09 15:22:14+00:00
State: open
Labels: implemented, rfc

Scope of Change
====
There will be a way to monitor FTP transfers.

Rationale
====
To be able to redraw the application UI and/or update a progressbar.

Functionality
====

Current functionality
----

```php
rootDir()->file($filename)->uploadFrom(new FileInputStream(new File($local)));

// Downloading
$c->rootDir()->getFile($filename)->downloadTo(new FileOutputStream(new File($local)));
?>
```
Both of these methods are blocking, that is, they will not return until
the transfer has been completed.

Transfer classes
----
There will be transfer classes representing up- and downloads:

```
lang.Object
|
`-+ peer.ftp.FtpTransfer
|
|-+ peer.ftp.FtpUpload
|
`-+ peer.ftp.FtpDownload

```
The FtpTransfer base class is declared as follows:

```php

```

Listener interface
----
There will be a new interface, peer.ftp.FtpTransferListener:

```php

```

With listeners
----

```php
compoundMessage(), ")");
}
}');

// Uploading
$file= $c->rootDir()->file($filename)->uploadFrom(
new FileInputStream(new File($local)),
FTP_BINARY,
$listener
);

// Downloading
$stream= $c->rootDir()->getFile($filename)->downloadTo(
new FileOutputStream(new File($local)),
FTP_BINARY,
$listener
);
?>
```

Output
----

```
peer.ftp.FtpUpload@(
io.streams.FileInputStream -> /php.exe
)
[.......]
Completed

peer.ftp.FtpDownload@(
/php.exe -> io.streams.FileOutputStream
)
[...................]
Completed

```

Alternative usage
----

```php
rootDir()->getFile($filename)->start(
FtpDownload::to(new FileOutputStream(new File($local)))
);
while (!$transfer->complete()) {
$transfer->perform();
}
?>
```

Security considerations
====
n/a

Speed impact
====
n/a

Dependencies
====
n/a

Related documents
====
- http://experiments.xp-framework.net/?arena,ftp
The new API

Comments
====
n/a