My current python script:
import ftplib
import hashlib
import httplib
import pytz
from datetime import datetime
import urllib
from pytz import timezone
import os.path, time
import glob
def ftphttp():
ts = os.path.getmtime('Desktop/images/frame00.png')
dt = datetime.fromtimestamp(ts, pytz.utc)
timeZone= timezone('Asia/Singapore')
#converting the timestamp in ISOdatetime format
localtime = dt.astimezone(timeZone).isoformat()
cam = "002"
lscam = localtime + cam
ftp = ftplib.FTP('localhost','kevin403','S$ip1234')
ftp.cwd('/var/www/html/image')
m=hashlib.md5()
m.update(lscam)
dd=m.hexdigest()
for image in glob.glob(os.path.join('Desktop/images/frame**.png')):
with open(image, 'rb') as file:
ftp.storbinary('STOR '+dd+ '.png', file)
x = httplib.HTTPConnection('localhost', 8086)
x.connect()
f = {'ts' : localtime}
x.request('GET','/camera/store?cam='+cam+'&'+urllib.urlencode(f)+'&fn='+dd)
y = x.getresponse()
z=y.read()
x.close()
ftp.quit()
As right now this line of code is only get one file timestamp:
ts = os.path.getmtime('Desktop/images/frame00.png').
But what if i send multiple file from a folder and get all the files timestamp. Is it possible to do it? I using ftplib to send multiple from a folder to another folder.