DronePlugin/BringCookies/main.py
katharina e8fe72a68f
Some checks reported errors
continuous-integration/drone/push Build was killed
#1: push main.py
2021-12-04 18:17:51 +01:00

21 lines
770 B
Python

import os
import requests
def main():
env = os.environ
sourcePath = env["PLUGIN_SOURCEPATH"]
destinationPath = env["PLUGIN_DESTINATIONPATH"]
nextcloudInstance = env["PLUGIN_NEXTCLOUDINSTANCE"]
user = env["PLUGIN_USER"]
password = env["PLUGIN_PASSWORD"]
protocol = env["PLUGIN_PROTOCOL"]
verifyTls = env["PLUGIN_VERIFYTLS"]
filecontent = open(sourcePath, "rb")
copy(nextcloudInstance, user, destinationPath, filecontent, password, protocol, verifyTls)
def copy(nc, user, pathtofile, filecontent, password, protocol, verifyTls):
journey = requests.put(protocol + "://" + nc + "/remote.php/dav/files/" + user + "/" + pathtofile, data=filecontent, auth=(user, password), verify=verifyTls)
if __name__ == "__main__":
main()