Ben Timby has committed code to PyFilesystem that lets you expose any filesystem over FTP. We've had the ability to serve filesystems over SFTP (secure ftp) and XMLRPC for a while, but plain old FTP was a glaring omission–until now.

You can serve the current directory programatically with something like the following:

from fs.expose.ftp import serve_fs
from fs.osfs import OSFS
serve_fs(OSFS('.'), '', 21)

The same functionality is also available to the fsserve command. The following is equivalent to the above code, but from the command line:

fsserve -t ftp .

You'll probably need root privileges (i.e. sudo) on Linux for these examples.

With the server running, you can browse the files on your home directory with an ftp client, or by typing “” in to your browser. Any of the other supported filesystems can be served in the same way.

FTP has been around since the dawn of the internet, so just about any network enabled device will be able to access files exposed this way. It's a great way of creating a gateway to other filesystems. You could expose files stored on Amazon S3 for example.

You'll need to check out the latest code from SVN to try this out.

Update: Ben has posted more about this.

This blog post was posted to It's All Geek to Me on Wednesday April 25th, 2012 at 10:09AM

4 Responses to "Serve FTP with Python and PyFilesystem"

  • April 25th, 2012, 4:20 p.m.

    I posted a bit more information on this same subject on my blog as well.

  • September 17th, 2013, 5:27 p.m.

    So - will we see version 0.5.0 soon?
    I'll give this a mention at PyConUk - I rather like this package - and it's intent. Building a mount fs, serving it up over FTP/SFTP makes things a doddle.

    The importhook is actually quite amazing too.

  • September 17th, 2013, 5:51 p.m.

    The version in trunk has come a long way. We have Python 3 compatibility now. A new release is probably overdue…

  • Alekibango
    October 7th, 2013, 2:07 p.m.

    Hi Will,

    I am really impressed by pyfilesystem. It made me write my own virtual system filesystem implementation in a day.

    But there is a big problem with google account requirement.

    Please, move the project to github (or bitbucket). Google is evil and svn is totally obsolete now.

Leave a Comment

You can use bbcode in the comment: e.g. [b]This is bold[/b], [url][/url], [code python]import this[/code]
Preview Posting...
Previewing comment, please wait a moment...

My Tweets

Will McGugan

My name is Will McGugan. I am an unabashed geek, an author, a hacker and a Python expert – amongst other things!

Search for Posts
Possibly related posts
Popular Tags
Recent Comments
def thousands_with_commas(number): new_number = [] number = str(number) mod_value = len(number) % 3 counter = 3 if len(number) 4: return ...
don't know why this was tempting.. (#1)import re from collections import Counter, OrderedDict cnt=Counter() with open(./t) as f: #--- strip ...
- Mike on Python Coder Test
Hello! I've seen this test and tried to do them. Result added bellow. First path: def thousands_with_commas(i): i = str(i) ...
Why another framework? what wrong with django, pyramid, flask?will be have answer for this question in the docs)
Hi! Really great code, good work! But trying to use it on a responsive site, it didn't resize images. So, ...
© 2008 Will McGugan.

A technoblog blog, design by Will McGugan