The pyftpdlib Library and How to Transfer Files Over the Network Between Different Devices | Hacker Noon

Pyftpdlib is a library for creating an FTP server in Python. It is the most complete RFC-959 FTP server implementation available for Python programming language. The library does not display the IP addresses by which our server is available, so you first have to find out or access it by the domain name. The most important thing is the speed of deployment, and you can download files from the device the server is running on. It can also work on the phone in hotspot mode. Unfortunately, newer versions of browsers have abandoned the FTP protocol.

image

Maksim Kuznetsov Hacker Noon profile picture

@exactorMaksim Kuznetsov

Just a Senior Python Developer.

I think every person has faced the problem of transferring data between devices when there is no desire or opportunity to upload any data to the cloud. In my personal opinion, this is one of the fastest ways to transfer files: we will talk about the pyftpdlib library.

The pyftpdlib Library

Information from PyPI:

Pyftpdlib – Python FTP server library provides a high-level portable interface to easily write very efficient, scalable, and asynchronous FTP servers with Python. It is the most complete RFC-959 FTP server implementation available for Python programming language and it’s used in projects like Google Chromium and Bazaar and included in Debian, Fedora, and FreeBSD package repositories.

Yes, you understood correctly this is a library for creating an FTP server in Python. Now we get to the most important thing – speed. Here you can understand 3 different speeds: download speed, upload speed, and deployment speed.

For the first two, the author has kindly posted benchmarks: More info and comparison with other libraries you can find here.

You can see the upload speed is 585.90 MB/sec and the download speed is 1652.72 MB/sec for one user.

image

My results are limited by 100 Megabit cable and I had 12 MB/sec download speed and the same result for upload speed. Using Wi-Fi transfer to the old tablet I had: 6.5MB/sec as upload speed and 8 MB/sec as download speed.

The author of this library claims that the C10K problem has been successfully resolved in pyftpdlib.

Transferring the files

And now the most important thing is the speed of deployment. By this, I mean installing and starting a minimally running server.

What you need to do:

  1. Install pyftpdlib using pip (pip3 install pyftpdlib)
  2. Run the server (python3 -m pyftpdlib)

Done. You have just started a minimal server for an anonymous user. Now you can download files from the device the server is running on. Note that the server runs on port 2121 by default. If you want to change port use flag

-p PORT_NUMBER

.

Do you want to upload something to the server? Add the

-w

flag to enable writing to the server.

python3 -m pyftpdlib -w

The -d flag will allow you to specify a specific directory for you, without it the server will use the directory you are in.

python3 -m pyftpdlib -w -d / path / to / your / folder

If you want to secure the connection, then use

-u
-P

in order to set the login and password, but then the anonymous user will be unavailable.

python3 -m pyftpdlib -u user1 -P hard_password_for_user1

This is why I like this method:

I think you’ve heard about termux. If not, then this is a console emulator for Android. Here you can also use this library and transfer files from your smartphone to your computer or another smartphone. A good solution if you lost your USB cable. It can also work on the phone in hotspot mode. Unfortunately, it was not possible to conduct a test on the iPhone, please check it if you have some. Unfortunately, newer versions of browsers have abandoned the FTP protocol, so you will have to use a file manager.

List of file managers:

  • FileZilla
  • mc (Midnight Commander)
  • Explorer (Windows)
  • pcmanfm (Linux)
  • etc…

But there is a small drawback: the library does not display the IP addresses by which our server is available, so you first have to find out or access it by the domain name.

I hope you can find this small guide useful for you and will help you if necessary.

Tags

Join Hacker Noon