-
-
Save icecreammatt/3ccf05a8c6c4d3f1ca30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from ftplib import FTP | |
| # Server connection string | |
| remoteUrl = 'ftp.debian.org' | |
| ftp = FTP(remoteUrl) | |
| # Login | |
| ftp.login() | |
| # Switch to folder | |
| ftp.cwd('debian') | |
| # List contents | |
| ftp.dir() | |
| # Upload file - Untested! | |
| # http://stackoverflow.com/a/17438193/873559 | |
| fileName = 'filename.txt' | |
| fileNameBinary = 'filename.bin' | |
| myFile = open(fileName, 'r') | |
| myFileBinary = open(fileNameBinary, 'rb') | |
| ftp.storbinary("RETR " + 'filename.txt', myFile) | |
| ftp.storlines("STOR " + 'filename.txt', myFileBinary) | |
| myFile.close() | |
| myFileBinary.close() | |
| ftp.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment