Running an FTP server on the N97

Introduction

Transferring files with bluetooth or via USB is practical, but I have been often wondering how practical it would be to transfer using FTP. FTP is supported pretty much everywhere. I recently played with PyS60 – A Python implementation for S60. It’s compatible with 3rd and 5th edition devices and thus with the N97. To my surprise it worked like a charm. It should work equally well for all S60 3rd and 5th edition devices.

Overview

Getting ftp on your N97 is straight forward:

  1. Install Python S60 on your phone
  2. Download pyftpdlib
  3. Write a little python script to start it

Getting PyS60 running on your phone

The Nokia opensource wiki has good documentation on how to get Python installed and operational on your phone:

http://wiki.opensource.nokia.com/projects/Installing_PyS60

It boils pretty much down to downloading PythonForS60_2.0.0.tar.gz and installing Python2.0.0 sis and one of the python shells.

The newest PyS60 is recommended, though at least on N97 I have initially got it working with version 1.9.4 as well.

Downloading pyftpdlib

First, you have to get the pyftpdlib targz. The author has used version 0.5.2. The archive consists of:

  • the actual library
  • demos
  • documentation
  • installer

You really only need the library and it is located in the pyftpdlib directory and consists of two files: __init__.py and ftpserver.py. I copied this directory (with the two files) over to the memory card of my phone into the root of it, but any other location works equally good for as long as you remember where you put it. 😉

Write a little python script

Both python 1.9.4 and python 2.0.0 had their example scripts in E:\data\python on the device, where E:\ is the memory card. The script you have to write is pretty much the Quick Start example on the home page of the pyftpdlib project. Only a few things need changing.

No matter where you put the pyftpdlib files , they won’t be in the standard search path, so we have to alter this path before we do anything else. Altering the path is done by importing the sys module and modifying the path variable:

import sys
sys.path.append( 'E:\\' )

The directory appended should be the one you copied the pyftpdlib into, E:\ is the root of the memory card and all backslashes have to be doubled.

What’s also different is what you share. In my case I wanted to have a Public directory on the memory card for anonymous access (in Apple fashion) and two private directories for both internal memory and the memory card. These are the users I added to the authorizer:

authorizer.add_user("drivec","password","C:\\", perm="elradfmw")
authorizer.add_user("drivee","password","E:\\", perm="elradfmw")
authorizer.add_anonymous( "E:\\Public" )

That’s pretty much it. Then you open up the python shell on your phone, select Run script from the menu and select your ftpd start script. It will log all the connection attempts and issued commands. A word of warning though: something seems to be missing from it, probably thread support. If you try to mount it with Apple Finder, it will mount, but the sheer amount of accesses will be a little too much for the server.

The complete start script is attached to this article.

Leave a Reply

Your email address will not be published. Required fields are marked *