Exchanging Files Over the Network the Easy Way

The age old problem: how do I send you these files with the least amount of effort. Have you ever been is this situation? You need to send bunch of files to another person sitting 3 feet away from you. Neither one of you is carrying any portable media. No thrumb drives, not blank CD’s or anything like that. What you do have is network connectivity.

The first thing people do in a situation like this is to reach for their email. Unfortunately email was never designed to be a file sharing medium. If you have a large number of big files to send over, email will not work. You could use one of the online file sharing services such as SendSpace or Rapidshare but they too have arbitrary file size limitations. Not only that, but your data will now be stored somewhere on the interwebs – in many cases this is unacceptable.

What do you do then?

A while ago I wrote about one possible solution to this problem – a mini HTTP server. That was a windows centric solution that used a proprietary freeware tool. Recently I discovered a much nicer solution that requires nothing but a standard Python installation.

Here is what you do. On the command line, navigate to the folder you want to share over the network, and issue the following command:

python -m SimpleHTTPServer 80

Boom! Instant HTTP server. All you need to do now is to instruct the other person to open a web browser and type in your current IP into the address bar. Easy, painless and awesome. Here is me running the server and accessing it at the same time:

SimpleHTTPServer in Action

As you can see, the server will actually show you information about every access attempt so you can have some evidence that no one but the authorized person accessed it while it was running.

Still, sharing the whole folder is not always desirable. Sometimes you want to transfer just a single big file. If you recall, I already shown you how to do this with Netcat. I’m going to continue with the Python centric theme and introduce you to a neat little script called woof.

Using it is very simple. Just do this:

python woof.py MyFileToBeShared.zip

That’s it. It creates a server on port 8080 and serves that particular file and nothing else. One disadvantage of this script seems to be that it seems to rely on something POSIX-y to work. In other words, it fails miserably in Windows environment but it should work in a real operating system.

Of course, sometimes you are in a reverse situation. Instead of having to send files, you need to receive them. Running a miniature HTTP server won’t help you. Or maybe it will. What you need is Droopy – another Python mini server. Instead of serving files however, it creates a file upload page that looks like this:

Droopy in action.

You can customize how this page looks by displaying a custom message and ever a picture below the upload form. But this is how it works. It is quite brilliant actually. Run it, tell the other person to navigate to your IP on port 8000 and upload the file. Very simple and very effective.

Keep these things in mind during your travels. I’d recommend installing Python to be the first thing you do whenever you get a new laptop.

What are your favorite python tricks? Or network file transfer tricks in general?

This entry was posted in programming and tagged . Bookmark the permalink.



7 Responses to Exchanging Files Over the Network the Easy Way

  1. Chris UNITED STATES Mozilla Firefox Windows Terminalist says:

    That’s pretty handy. Bookmarked for future reference.

    Reply  |  Quote
  2. mcai8sh4 UNITED KINGDOM Google Chrome Linux Terminalist says:

    I’ve been using woof and droopy for a while now – and find them amazingly useful. Woof also allows you to set the number of times to share the file before it shuts down! Also if you want to share a directory, then ‘woof ~/stuff/’ will automatically zip (or tar…) the directory and share that.

    After reading this post I thought I’d check to see if there are any updates… and yes there are – using ‘woof -U’ allows people to upload files to you (exactly what droopy does!)

    I also learnt about the SimpleHTTPServer recently (from our friendly host, Luke) and found that using ‘python -m SimpleHTTPServer 9009 >> .webserve_log 2>&1 &’ runs it in the background and creates a log file of accesses called .webserve_log. Set this as an alias (in a real OS) and there you have a very easy way to share you’re current dir, whilst still being able to use your current shell.

    Reply  |  Quote
  3. IceBrain PORTUGAL Mozilla Firefox Linux Terminalist says:

    Meh, I’d just create a network share. It’s built-in in Windows and I keep Samba installed on Linux. I just need to add three lines to /etc/samba/smb.conf:

    [SHARE_NAME]
    path = /path/to/dir
    public = yes

    And then I do /etc/init.d/samba start, and tell the person to add a network share and write “\\my_ip\share_name”

    There’s two advantages:
    1) They can send multiples files or a whole folder without having to send each file separately or zip/unzip them.
    2) It actually has a progress bar and an approximation of the remaining time (which browsers should have a long time ago).

    Of course, if I was controlling both PCs myself I would just use rsync, it works on Windows too.

    Reply  |  Quote
  4. Luke Maciak UNITED STATES Mozilla Firefox Linux Terminalist says:

    @ mcai8sh4:

    Did not notice the -U option on Woof. Thanks!

    @ IceBrain:

    Yep, that’s usually the easiest way to do this. Sometimes it doesn’t work tat nicely due to lack of admin privileges on the machine or a locked down firewall that will block access to network shares.

    Also, have you ever tried to have a completely clueless person try to add a network share? It usually goes like this:

    1. Tell them to type in \\ipaddress\share into the address bar
    2. Realize the address bar is disabled in Explorer by default
    4. Instead of enabling it, show them the ‘Mount Network Drive’ method
    5. Realize they have a firewall that is blocking the connection
    6. Ask them about the firewall
    7. Explain what a firewall is and how it would have an icon in the task bar
    8. Watch the person fumble around their desktop looking for that elusive “Symtex” or “MyCoffee” icon
    9. Get annoyed, walk over and do it for them

    HTTP has the advantage of being easy and never hindered by firewalls – you just email the person a link and it works.

    Reply  |  Quote
  5. Adrian BELGIUM Mozilla Linux says:

    I just tried it on my linux box and it worked perfectly.. Using the browser on my linux box.

    Would this bypass a firewall on the router of my home network? I don’t administer this router but I’d still like to be able to access it from another computer, anywhere in the world.

    Reply  |  Quote
  6. road UNITED STATES Google Chrome Windows says:

    this is exactly why I always install Cygwin + openSSH on every Windows box I touch…

    Reply  |  Quote
  7. GDR! POLAND Opera Linux says:

    Then, there is Opera United ;)

    Reply  |  Quote

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>