Skip to main content

ftp client/server for asyncio

Project description

Travis status for master branch https://codecov.io/gh/aio-libs/aioftp/branch/master/graph/badge.svg https://img.shields.io/pypi/v/aioftp.svg https://img.shields.io/pypi/pyversions/aioftp.svg https://pypi-badges.global.ssl.fastly.net/svg?package=aioftp&timeframe=monthly

ftp client/server for asyncio (http://aioftp.readthedocs.org)

Features

  • Simple.

  • Extensible.

  • Proxy via twunnel3.

Goals

  • Minimum usable core.

  • Do not use deprecated or overridden commands and features (if possible).

  • Very high level api.

Client use this commands: USER, PASS, ACCT, PWD, CWD, CDUP, MKD, RMD, MLSD, MLST, RNFR, RNTO, DELE, STOR, APPE, RETR, TYPE, PASV, ABOR, QUIT, REST, LIST (as fallback)

Server support this commands: USER, PASS, QUIT, PWD, CWD, CDUP, MKD, RMD, MLSD, LIST (but it’s not recommended to use it, cause it has no standard format), MLST, RNFR, RNTO, DELE, STOR, RETR, TYPE (“I” and “A”), PASV, ABOR, APPE, REST

This subsets are enough for 99% of tasks, but if you need something, then you can easily extend current set of commands.

Server benchmark

Compared with pyftpdlib and checked with its ftpbench script.

aioftp 0.8.0

STOR (client -> server)                              284.95 MB/sec
RETR (server -> client)                              408.44 MB/sec
200 concurrent clients (connect, login)                0.18 secs
STOR (1 file with 200 idle clients)                  287.52 MB/sec
RETR (1 file with 200 idle clients)                  382.05 MB/sec
200 concurrent clients (RETR 10.0M file)              13.33 secs
200 concurrent clients (STOR 10.0M file)              12.56 secs
200 concurrent clients (QUIT)                          0.03 secs

pyftpdlib 1.5.2

STOR (client -> server)                             1235.56 MB/sec
RETR (server -> client)                             3960.21 MB/sec
200 concurrent clients (connect, login)                0.06 secs
STOR (1 file with 200 idle clients)                 1208.58 MB/sec
RETR (1 file with 200 idle clients)                 3496.03 MB/sec
200 concurrent clients (RETR 10.0M file)               0.55 secs
200 concurrent clients (STOR 10.0M file)               1.46 secs
200 concurrent clients (QUIT)                          0.02 secs

Dependencies

  • Python 3.5.3+

License

aioftp is offered under the Apache 2 license.

Library installation

pip install aioftp

Getting started

Client example

import asyncio
import aioftp


async def get_mp3(host, port, login, password):
    async with aioftp.ClientSession(host, port, login, password) as client:
        for path, info in (await client.list(recursive=True)):
            if info["type"] == "file" and path.suffix == ".mp3":
                await client.download(path)


loop = asyncio.get_event_loop()
tasks = (
    get_mp3("server1.com", 21, "login", "password")),
    get_mp3("server2.com", 21, "login", "password")),
    get_mp3("server3.com", 21, "login", "password")),
)
loop.run_until_complete(asyncio.wait(tasks))
loop.close()

Server example

import asyncio
import aioftp


loop = asyncio.get_event_loop()
server = aioftp.Server()
loop.run_until_complete(server.start(None, 8021))
try:
    loop.run_forever()
except KeyboardInterrupt:
    loop.run_until_complete(server.close())
    loop.close()

Or just use simple server

python -m aioftp --help

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioftp-0.13.0.tar.gz (87.1 kB view details)

Uploaded Source

Built Distribution

aioftp-0.13.0-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file aioftp-0.13.0.tar.gz.

File metadata

  • Download URL: aioftp-0.13.0.tar.gz
  • Upload date:
  • Size: 87.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for aioftp-0.13.0.tar.gz
Algorithm Hash digest
SHA256 5711c03433b510c101e9337069033133cca19b508b5162b414bed24320de6c18
MD5 804eb42a4910967808315c868ae9f79a
BLAKE2b-256 83d5f6b10ec9d582f994fb98ea677f8c1f8e68a6e47914d74d716399f95cb699

See more details on using hashes here.

File details

Details for the file aioftp-0.13.0-py3-none-any.whl.

File metadata

  • Download URL: aioftp-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for aioftp-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11b5fab43a40f08452e320bc764275c793a63bc0ddd59df80376254da8715dd5
MD5 026e688e2f27565732f806d89e2163d5
BLAKE2b-256 c7f7ab4ac2b8103ba9d06d3199988431fbe406d0d91a211e8569cd16075146fd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page