Created
April 20, 2013 01:16
-
-
Save tylerthebuildor/5424303 to your computer and use it in GitHub Desktop.
Comprehensive FTP class
This file contains 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
import ftplib | |
from ftplib import FTP | |
# Ftp Class | |
class Ftp: | |
conn = False | |
def __init__(self, address, user, password): | |
self.address = address | |
self.user = user | |
self.password = password | |
def connect(self): | |
Ftp.conn = FTP(self.address) | |
Ftp.conn.login(self.user, self.password) | |
def read(self): | |
return None | |
def upload(self, localFile, remoteDir): | |
file = open(localFile, "rb") | |
Ftp.conn.cwd(remoteDir) | |
Ftp.conn.storbinary('STOR ' + localFile, file) | |
file.close() | |
def download(self, remoteFile, localDir): | |
return None | |
def close(self): | |
Ftp.conn.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment