Go to file
monomono2 cbb012be47
add sudo note for port to README.md
2021-04-21 10:22:06 -05:00
README.md add sudo note for port to README.md 2021-04-21 10:22:06 -05:00
py-file-upload.py Created README.md and uploaded code to GitHub 2015-11-06 17:57:28 -05:00

README.md

Python File Transfer Server

This is a server written in Python to transfer files from one UNIX/Linux machine to another.

I built this partly because I had to auto-transfer files between two machines at work, but mainly because I wanted to have some fun and create a quick hack. So, I tried to do both.

The server is meant as a file transfer utility between machines that do not have FTP/SCP services running. It only allows transfer of files through POST and does not support GET requests. Additionally, it also allows changing the owner and group of the file on the server. I added this feature to allow my colleagues to transfer files across the machines and preserve their ownership over it.

Usage

On the server which receives the files, use sudo ./py-file-upload.py to start the server.

Without sudo:

  • The chmod and chown function will not work, but file transfer will still work.
  • The default port 80 requires privilegies, you must change de port 80 to other port (8080 by example) at end of the file py-file-upload.py.

From the client machine, use curl or other utility to submit a form to the server:

curl -F sfname=/absolute-path/on-server/my_file.txt \
    -F "file=@/file-to-copy/test_file.txt" \
    <-F user=owner-name \>
    <-F group=group-name \>
    http://myserver-ip-address:port
  • sfname is the absolute path of the file on the server. Only absolute paths are allowed since I wanted the users to specify where they want to place the files.
  • file is the file to copy from the client. Path can be relative or absolute.
  • user and group is the intended owner of the file on the server. These are optional.