DronePlugin/BringCookies/main.py

21 lines
770 B
Python
Raw Normal View History

2021-12-04 17:17:51 +00:00
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()