#141: Added file upload capability. Next is app testing

This commit is contained in:
frikky
2020-11-22 12:48:54 +01:00
parent 6b48cfe8cc
commit 81d3f02fff
2 changed files with 26 additions and 170 deletions
+24 -2
View File
@@ -833,6 +833,26 @@ class AppBase:
print("SHOULD GET FILES BASED ON ORG %s, workflow %s and value(s) %s" % (org_id, full_execution["workflow"]["id"], value))
get_path = "/api/v1/files/%s/content?execution_id=%s" % (value, full_execution["execution_id"])
print("PATH: %s" % get_path)
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer %s" % self.authorization
}
ret = requests.get("%s%s" % (self.url, get_path), headers=headers)
if ret.status_code == 200:
return ret.text
print("ERROR GETTING FILE: ")
print("FILE RET CONTENT: %s" % ret.text)
print("FILE RET CODE FILE: %d" % ret.status_code)
# Sets files in the backend
def set_files(full_execution, files[]):
print("FULL EXEC: %s" % full_execution)
org_id = full_execution["workflow"]["execution_org"]["id"]
print("SHOULD GET FILES BASED ON ORG %s, workflow %s and value(s) %s" % (org_id, full_execution["workflow"]["id"], value))
get_path = "/api/v1/files/%s/content?execution_id=%s" % (value, full_execution["execution_id"])
print("PATH: %s" % get_path)
headers = {
"Content-Type": "application/json",
@@ -842,8 +862,6 @@ class AppBase:
print("RET CONTENT: %s" % ret.text)
print("RET CODE FILE: %d" % ret.status_code)
# r.HandleFunc("/api/v1/files/{fileId}/content", handleGetFileContent).Methods("GET", "OPTIONS")
# Checks whether conditions are met, otherwise set
branchcheck, tmpresult = check_branch_conditions(action, fullexecution)
if not branchcheck:
@@ -911,6 +929,8 @@ class AppBase:
multiexecution = False
multi_execution_lists = []
for parameter in action["parameters"]:
# This code handles files.
is_file = False
try:
if parameter["schema"]["type"] == "file":
@@ -920,6 +940,8 @@ class AppBase:
except KeyError as e:
print("SCHEMA ERROR: %s" % e)
check, value, is_loop = parse_params(action, fullexecution, parameter)
if check:
raise "Value check error: %s" % Exception(check)