fotobox/uploader.py

36 lines
1.0 KiB
Python

import logging
import subprocess
from webdav3.client import Client
from xmlrpc.client import DateTime
import os
LOGGER = logging.getLogger(__name__)
def sync_photo(photo_path):
# hochladen des bildes
LOGGER.info("Uploading file..")
LOGGER.info(os.path.isfile(photo_path))
subprocess.run(
["rclone", "copy", "{}".format(photo_path), "https://cloud.bauhaeusle.de/remote.php/dav/files/admin"]
)
LOGGER.info("photo uploaded!")
def sync_photo2(photo_path):
options = {
'webdav_hostname': "https://cloud.bauhaeusle.de/remote.php/dav/files",
'webdav_login': "bh",
'webdav_password': "forever2023!"
}
client = Client(options)
client.verify = False # To not check SSL certificates (Default = True)
#client.session.proxies(...) # To set proxy directly into the session (Optional)
#client.session.auth(...) # To set proxy auth directly into the session (Optional)
client.upload_sync(remote_path="/bh/BestOf/Fotobox/" + photo_path.split("/")[-1] , local_path=photo_path)