I am sending a file via FTP using Phyton.
My code:
#!/usr/bin/python
import ftplib
import os
filename = "MyFile"
ftp = ftplib.FTP("xx.xx.xx.xx")
ftp.login("UID", "PSW")
ftp.cwd("/Unix/Folder/where/I/want/to/put/file")
os.chdir(r"\windows\folder\which\has\file")
myfile = open(filename, 'r')
ftp.storlines('STOR ' + filename, myfile)
myfile.close()
The problem is with the use of ftp.storlines()
or ftp.storbinary()
. In the case that the file is binary or text type.
How do I determine which command I should use? Can it always be sent as a binary regardless of what it is?