parent
a57747e72a
commit
4a061b094f
@ -0,0 +1,39 @@
|
||||
def Recieve(inRequest, inGsettings ):
|
||||
if inRequest.headers.get('Content-Length') is not None:
|
||||
lInputByteArrayLength = int(inRequest.headers.get('Content-Length'))
|
||||
lInputByteArray = inRequest.rfile.read(lInputByteArrayLength)
|
||||
#print(f"BoDY:{lInputByteArray}")
|
||||
# Extract bytes data
|
||||
lBoundaryStr = str(inRequest.headers.get('Content-Type'))
|
||||
lBoundaryStr = lBoundaryStr[lBoundaryStr.index("boundary=")+9:] # get the boundary key
|
||||
#print(lBoundaryStr)
|
||||
lSplit = lInputByteArray.split(b'\r\n\r\n')
|
||||
lDelimiterRNRNIndex = lInputByteArray.index(b'\r\n\r\n')
|
||||
#print(lSplit)
|
||||
# Get file name
|
||||
lSlit0 = lInputByteArray[:lDelimiterRNRNIndex].split(b'\r\n')[1]
|
||||
lFileNameBytes = lSlit0[lSlit0.index(b'filename="')+10:-1]
|
||||
lFileNameStr = lFileNameBytes.decode("utf-8")
|
||||
# File data bytes
|
||||
lFileDataBytes = lInputByteArray[lDelimiterRNRNIndex+4:]
|
||||
lFileDataBytes = lFileDataBytes[:lFileDataBytes.index(b"\r\n--"+lBoundaryStr.encode("utf-8"))]
|
||||
# Create file name
|
||||
lNowDatetime = datetime.datetime.now()
|
||||
lFileNameStr = lNowDatetime.strftime("%H_%M_%S_%f") + "." + lFileNameStr.split(".")[-1] # Generate filename
|
||||
# Save the file
|
||||
lFile = open(os.path.join(gRobotInputFolderStr, lFileNameStr),"wb")# Save to file
|
||||
lFile.write(lFileDataBytes)
|
||||
lFile.close() # Close the file
|
||||
# Add info about task in gSettings
|
||||
lTaskRecord = {
|
||||
"Datetime": lNowDatetime, # Datetime for start
|
||||
"IsReadyBool": False, # Is result file ready
|
||||
"UserADStr": inRequest.OpenRPA["User"] # User, who send a task
|
||||
}
|
||||
inGSettings["Storage"][gRobotKeyStr]["TaskDict"][lFileNameStr]=lTaskRecord # Set the record
|
||||
#print(inRequest.headers)
|
||||
lResponseDict = inRequest.OpenRPAResponseDict
|
||||
# Send response status code
|
||||
lResponseDict["StatusCode"]=303 # Redirect after form submit to main orchestrator page
|
||||
# Send headers
|
||||
lResponseDict["Headers"]["Location"]="/"
|
Loading…
Reference in new issue