08.02.2023, 11:21
Try this. filedata variable must contain your image in JPEG format. Use io.readfile() to read a local file.
For digest auth you can use this example: https://forum.logicmachine.net/showthrea...64#pid9364
Replace ssl.https.request in the above code with request from the digest code.
Code:
require('ltn12')
require('ssl.https')
boundary = os.date('%d%m%Y%H%M%S')
filedata = '...' -- image data as a binary string
body = table.concat({
'--' .. boundary,
'Content-Disposition: form-data; name="blob-image"; filename="picture.jpeg"',
'Content-Type: image/jpeg',
'',
filedata,
'--' .. boundary .. '--',
''
}, '\r\n')
resp = {}
res, code, response_headers, status = ssl.https.request({
url = 'https://test:test@10.0.0.230/api/display/image?display=ext1',
sink = ltn12.sink.table(resp),
method = 'PUT',
source = ltn12.source.string(body),
headers = {
['content-length'] = #body,
['content-type'] = 'multipart/form-data; boundary=' .. boundary
}
})
log(res, code, table.concat(resp))
For digest auth you can use this example: https://forum.logicmachine.net/showthrea...64#pid9364
Replace ssl.https.request in the above code with request from the digest code.