I and my friend have undertaken a small project as our plan for the summer and we were trying to employ FTP using python as a part of the project. We can successfully transfer the files over the same network but we have no clue as to how we can transfer files when we connected by internet(by a different network). I have added the code for your reference. I new to both FTP and python,it would be great if somebody can help us out.
Server side program:
#server.py from pyftpdlib.ftpserver import DummyAuthorizer from pyftpdlib.ftpserver import FTPHandler from pyftpdlib.ftpserver import FTPServer authorizer = DummyAuthorizer() authorizer.add_user("user", "12345", "/", perm="elradfmw") authorizer.add_anonymous("/") handler = FTPHandler handler.authorizer = authorizer server = FTPServer(("xxx.xxx.x.x", 2121), handler) server.serve_forever()
And the client program:
#client.py import ftplib fileTransfer = ftplib.FTP() fileTransfer.connect("xxx.xxx.x.x",2121) fileTransfer.login('user','12345') fileTransfer.retrlines('LIST') fileTransfer.cwd('/home/royal/MyPrograms/Python') fileTransfer.retrbinary('RETR Florida.mp3',open('club.mp3','wb').write)
I am working behind a NAT.