| 1 |
.. aioftp documentation master file, created by |
| 2 |
sphinx-quickstart on Fri Apr 17 16:21:03 2015. |
| 3 |
You can adapt this file completely to your liking, but it should at least |
| 4 |
contain the root `toctree` directive. |
| 5 |
|
| 6 |
aioftp |
| 7 |
====== |
| 8 |
|
| 9 |
ftp client/server for asyncio. |
| 10 |
|
| 11 |
.. _GitHub: https://github.com/aio-libs/aioftp |
| 12 |
|
| 13 |
Features |
| 14 |
-------- |
| 15 |
|
| 16 |
- Simple. |
| 17 |
- Extensible. |
| 18 |
- Client socks proxy via `siosocks <https://github.com/pohmelie/siosocks>`_ |
| 19 |
(`pip install aioftp[socks]`). |
| 20 |
|
| 21 |
Goals |
| 22 |
----- |
| 23 |
|
| 24 |
- Minimum usable core. |
| 25 |
- Do not use deprecated or overridden commands and features (if possible). |
| 26 |
- Very high level api. |
| 27 |
|
| 28 |
Client use this commands: USER, PASS, ACCT, PWD, CWD, CDUP, MKD, RMD, MLSD, |
| 29 |
MLST, RNFR, RNTO, DELE, STOR, APPE, RETR, TYPE, PASV, ABOR, QUIT, REST, LIST |
| 30 |
(as fallback) |
| 31 |
|
| 32 |
Server support this commands: USER, PASS, QUIT, PWD, CWD, CDUP, MKD, RMD, MLSD, |
| 33 |
LIST (but it's not recommended to use it, cause it has no standard format), |
| 34 |
MLST, RNFR, RNTO, DELE, STOR, RETR, TYPE ("I" and "A"), PASV, ABOR, APPE, REST |
| 35 |
|
| 36 |
This subsets are enough for 99% of tasks, but if you need something, then you |
| 37 |
can easily extend current set of commands. |
| 38 |
|
| 39 |
Server benchmark |
| 40 |
---------------- |
| 41 |
|
| 42 |
Compared with `pyftpdlib <https://github.com/giampaolo/pyftpdlib>`_ and |
| 43 |
checked with its ftpbench script. |
| 44 |
|
| 45 |
aioftp 0.8.0 |
| 46 |
|
| 47 |
:: |
| 48 |
|
| 49 |
STOR (client -> server) 284.95 MB/sec |
| 50 |
RETR (server -> client) 408.44 MB/sec |
| 51 |
200 concurrent clients (connect, login) 0.18 secs |
| 52 |
STOR (1 file with 200 idle clients) 287.52 MB/sec |
| 53 |
RETR (1 file with 200 idle clients) 382.05 MB/sec |
| 54 |
200 concurrent clients (RETR 10.0M file) 13.33 secs |
| 55 |
200 concurrent clients (STOR 10.0M file) 12.56 secs |
| 56 |
200 concurrent clients (QUIT) 0.03 secs |
| 57 |
|
| 58 |
pyftpdlib 1.5.2 |
| 59 |
|
| 60 |
:: |
| 61 |
|
| 62 |
STOR (client -> server) 1235.56 MB/sec |
| 63 |
RETR (server -> client) 3960.21 MB/sec |
| 64 |
200 concurrent clients (connect, login) 0.06 secs |
| 65 |
STOR (1 file with 200 idle clients) 1208.58 MB/sec |
| 66 |
RETR (1 file with 200 idle clients) 3496.03 MB/sec |
| 67 |
200 concurrent clients (RETR 10.0M file) 0.55 secs |
| 68 |
200 concurrent clients (STOR 10.0M file) 1.46 secs |
| 69 |
200 concurrent clients (QUIT) 0.02 secs |
| 70 |
|
| 71 |
Dependencies |
| 72 |
------------ |
| 73 |
|
| 74 |
- Python 3.10+ |
| 75 |
|
| 76 |
0.13.0 is the last version which supports python 3.5.3+ |
| 77 |
|
| 78 |
0.16.1 is the last version which supports python 3.6+ |
| 79 |
|
| 80 |
0.21.4 is the last version which supports python 3.7+ |
| 81 |
|
| 82 |
0.22.3 is the last version which supports python 3.8+ |
| 83 |
|
| 84 |
0.26.3 is the last version which supports python 3.9+ |
| 85 |
|
| 86 |
License |
| 87 |
------- |
| 88 |
|
| 89 |
aioftp is offered under the Apache 2 license. |
| 90 |
|
| 91 |
Library installation |
| 92 |
-------------------- |
| 93 |
|
| 94 |
:: |
| 95 |
|
| 96 |
pip install aioftp |
| 97 |
|
| 98 |
Getting started |
| 99 |
--------------- |
| 100 |
|
| 101 |
Client example |
| 102 |
|
| 103 |
**WARNING** |
| 104 |
|
| 105 |
For all commands, which use some sort of «stats» or «listing», ``aioftp`` tries |
| 106 |
at first ``MLSx``-family commands (since they have structured, machine readable |
| 107 |
format for all platforms). But old/lazy/nasty servers do not implement this |
| 108 |
commands. In this case ``aioftp`` tries a ``LIST`` command, which have no |
| 109 |
standard format and can not be parsed in all cases. Take a look at |
| 110 |
`FileZilla <https://svn.filezilla-project.org/filezilla/FileZilla3/trunk/src/engine/directorylistingparser.cpp?revision=7322&view=markup>`_ |
| 111 |
«directory listing» parser code. So, before creating new issue be sure this |
| 112 |
is not your case (you can check it with logs). Anyway, you can provide your own |
| 113 |
``LIST`` parser routine (see the client documentation). |
| 114 |
|
| 115 |
.. code-block:: python |
| 116 |
|
| 117 |
import asyncio |
| 118 |
import aioftp |
| 119 |
|
| 120 |
|
| 121 |
async def get_mp3(host, port, login, password): |
| 122 |
async with aioftp.Client.context(host, port, login, password) as client: |
| 123 |
for path, info in (await client.list(recursive=True)): |
| 124 |
if info["type"] == "file" and path.suffix == ".mp3": |
| 125 |
await client.download(path) |
| 126 |
|
| 127 |
|
| 128 |
async def main(): |
| 129 |
tasks = [ |
| 130 |
asyncio.create_task(get_mp3("server1.com", 21, "login", "password")), |
| 131 |
asyncio.create_task(get_mp3("server2.com", 21, "login", "password")), |
| 132 |
asyncio.create_task(get_mp3("server3.com", 21, "login", "password")), |
| 133 |
] |
| 134 |
await asyncio.wait(tasks) |
| 135 |
|
| 136 |
asyncio.run(main()) |
| 137 |
|
| 138 |
Server example |
| 139 |
|
| 140 |
.. code-block:: python |
| 141 |
|
| 142 |
import asyncio |
| 143 |
import aioftp |
| 144 |
|
| 145 |
|
| 146 |
async def main(): |
| 147 |
server = aioftp.Server([user], path_io_factory=path_io_factory) |
| 148 |
await server.run() |
| 149 |
|
| 150 |
asyncio.run(main()) |
| 151 |
|
| 152 |
Or just use simple server |
| 153 |
|
| 154 |
.. code-block:: shell |
| 155 |
|
| 156 |
python -m aioftp --help |
| 157 |
|
| 158 |
Further reading |
| 159 |
--------------- |
| 160 |
|
| 161 |
.. toctree:: |
| 162 |
:maxdepth: 2 |
| 163 |
|
| 164 |
client_tutorial |
| 165 |
server_tutorial |
| 166 |
developer_tutorial |
| 167 |
client_api |
| 168 |
server_api |
| 169 |
common_api |
| 170 |
path_io_api |
| 171 |
|
| 172 |
Indices and tables |
| 173 |
------------------ |
| 174 |
|
| 175 |
* :ref:`genindex` |
| 176 |
* :ref:`search` |