Closed feeph closed 8 months ago
I figured it out by reading through the code.
The documentation wasn't helpful because a crucial part was not documented.
# this is basically just an identifier
# (it can be anything we want it to be)
img_name = 'cpu-temp'
# load the image's content as a binary value
img_data = open('img/cpu-temp.png', 'rb')
# prepare payload for the POST request
# - this part is not mentioned in the documentation
# - the key MUST be 'imgfile'
payload = {
'imgfile': img_data,
}
requests.post(
'http://localhost:5340/api/v0/dial/{dial.uid}/image/set',
params={
'key': <apikey>,
'imgfile': img_name,
},
files=payload,
)
Hi @feeph
Thanks for the feedback! This issue is probably more appropriate for the documentation instead of VU server. Please feel free to suggest/contribute to the VU documentation to help others who have similar question.
Added clarification in the VU API documentation that the image file should be uploaded as form-data.
Hello
First things first: Thank You! The documentation and the server app really helps to get started.
Unfortunately I'm running into an issue when trying to set a new background image using the Dial API. https://docs.vudials.com/api/dial_UID_image_set/ says you need to provide a filename as a parameter and to me it's not clear how that is supposed to work.
As far as I understand it is assumed the file is already stored in some magic location and this API call merely selects the stored file.
The documentation says
but I didn't find a description how to upload a file.
proposed solution:
Since
/api/v0/dial/{uid}/image/get
returns the actual image data as a data stream I would prefer if/api/v0/dial/{uid}/image/set
requires the API user to upload the image data as a data stream as well. That way the server can store the image data wherever it's needed (e.g. cache the checksum in the SQLite database and upload the image data to the dials).If it is preferred to keep the existing implementation then I would suggest to rename the API endpoints, e.g.: