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('.'), '127.0.0.1', 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 “ftp://127.0.0.1” 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.

    http://ben.timby.com/?p=195

  • 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]http://www.willmcgugan.com[/url], [code python]import this[/code]
Preview Posting...
Previewing comment, please wait a moment...
Will McGugan

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

You are reading my tech blog. See the homepage for my other blogs.

Search for Posts
Possibly related posts
Tags
Popular Tags
 
Archives
2013
 
Recent Comments
Hey Will thanks for the information. I will keep that in mind.
Hey Will thanks for the information. I will keep that in mind.
Hey Will thanks for the information. I will keep that in mind.
Sir, can you give me full code.?
Trying to implement this code. What are the requirements? Does it need a certain version of PHP, etc? Do I ...
 
© 2008 Will McGugan.

A technoblog blog, design by Will McGugan