How can I create an ftp server?

Do you know of a simple way to get an ftp server up and running in an Xperia X with paid Sailfish? I would like to transfer photos from a Sony camera that way. Preferably the server should also be available through wlan hotspot.

Don’t know if it works ok, but there is PyFTP at openrepos…

I’m not sure if that would work, if it actually uses http and not ftp. Maybe I’ll give that a try at some point if I don’t find a better solution.

When I understand the docs correctly, PyFTP is a client, not a server. But you can as root install pyftpdlib:

# pip3 install pyftpdlib
# wget https://raw.githubusercontent.com/giampaolo/pyftpdlib/master/demo/unix_ftpd.py
# python3 ./unix_ftpd.py

Now you can ftp into your phone as user nemo with the password configured in settings under developer tools.

If not available, you can install pip3 with zypper install python3-pip.

2 Likes

I’d also say pyftpdlib.
But you would need some -very small- python experience.

ncftpd would also be good, but there is only the client version ncftp by nieldk.
PyFTP may suffice.

But there is also “FTP server” by dipesh on openrepos (not affiliated, not tested, no guaranty).

1 Like

Is your purpose only synchronization of photos over your WLAN network or do you require other features FTP provides you with (e.g. desktop clients on other side)?
If not, have a look at rsync over ssh connection. Only thing you would need is developer mode (or: a manual install and setup of sshd) and a ssh key file / password setup on your phone. Then you conveniently can copy files to and from SFOS. Any directory you’re able to access as user on the phone will be available remotely. rsync is configurable to use very efficient and fast network transfer protocols

Benefit: SSHD runs as a system daemon. A manually launched python script (like pyftplib) doesn’t so that wouldn’t survive a reboot.

Since I’m advertising this: Leveraging SSH, on Linux systems you can even go so far as to mount your phone’s internal storage into your file system as if it were a flash or external hard drive

3 Likes

Thanks for the replies. I think pyftpdlib seems to be the best option for me. I know some basics of python syntax, but haven’t really used it on the phone and don’t know the details of how/where packages are installed etc. For example, how would a Sailfish update affect the pip3 or pyftpdlib installation?

I have actually been using rsync to sync some files between my XIGMANAS server and phone, and that works well. But the use case here is that my Sony a7C camera has ftp upload functionality, and therefore I need an ftp server. I got it working for the XIGMANAS but I would also like to transfer photos to my phone directly and on the go.

I think I’ll try the pyftpdlib and report back my findings.

There’s also https://openrepos.net/content/dipesh/ftp-server and it worked fine on 3.4 (no idea about 4.0) with the fix from top comment (one or two qml files need tweaking)
edit: also you can throw in ZeroTierOne (https://openrepos.net/content/theyosh/zerotier-one) and be able to access your phone through ftp using mobile data too, not only on wlan

2 Likes

I gave the pyftpdlib a try and it works very nicely. Here are the steps to reproduce:

  1. download the python script for running the ftp server (for example in /home/nemo/scripts):
    https://raw.githubusercontent.com/giampaolo/pyftpdlib/master/demo/unix_ftpd.py
  2. set the SSH access password in developer tools
  3. run terminal commands:

devel-su
pckon install python3-pip
pip3 install pyftpdlib
python3 /home/nemo/scripts/unix_ftpd.py

  1. now it should say something like:
    starting FTP server on 0.0.0.0:21, pid=12345
    You can stop the server by hitting ctrl+c.

At this point I could only access the ftp server from the Sailfish device itself (through browser), but not from any LAN device. I fixed this by editing the python script to use port 2121 instead of 21. Now it works with the camera using external wlan and hotspot as well. To check the ip address to access the ftp server you can use “ifconfig -a” and check the “inet addr” of “wlan0” or “tether” (for hotspot use).

That ZeroTierOne would surely be useful for certain scenarios, thanks for the tip. But for now I’ll just use the hotspot if I need to transfer on the go.

1 Like