You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the code that the process should execute (myprocess.py):
def execute(self, data):
mimetype = 'application/json'
file= data.get('file', None)
with open(file, mode='rb') as myfile: # b is important -> binary
fileContent = myfile.read()
outputs = {
'result': fileContent
}
return mimetype, outputs
This is another independant python script that calls my process:
filePath=r'C:\dev\test.txt'
url='http://localhost:5000/processes/myprocess/execution'
with open(filePath, "rb") as text_file:
data = {
"inputs": {
"file": text_file
}
}
r = requests.post(url, json=data)
print(r.content)
I tried many ways and I either get an error message when converting my binary as json:
TypeError: Object of type BufferedReader is not JSON serializable
Or I get a 'missing parameters' message from the process (for instance if I try to base64 encode the binary)
Please, can you provide me with an example?
Also, I posted the question on StackOverflow but I didn't manage to use the 'pygeoapi' tag, i have this error message (it doesn't appear in the tag list):
Tags
: [file], [process], [upload], [pygeoapi]
Creating the new tag 'pygeoapi' requires at least 1500 reputation. Try something from the existing tags list instead.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I try to build a test process that can read data from a file (just a text file containing "hello world" string).
I managed to make my process available at the process rest endpoint : http://localhost:5000/processes/myprocess
But I don't know how to pass my text file as an input parameter. I didn't find any example.
This is my input metadata (myprocess.py) :
This is the code that the process should execute (myprocess.py):
This is another independant python script that calls my process:
I tried many ways and I either get an error message when converting my binary as json:
Or I get a 'missing parameters' message from the process (for instance if I try to base64 encode the binary)
Please, can you provide me with an example?
Also, I posted the question on StackOverflow but I didn't manage to use the 'pygeoapi' tag, i have this error message (it doesn't appear in the tag list):
Tags
: [file], [process], [upload], [pygeoapi]
Creating the new tag 'pygeoapi' requires at least 1500 reputation. Try something from the existing tags list instead.
Beta Was this translation helpful? Give feedback.
All reactions