21 lines
770 B
Python
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()
|