Lua 示例
local https = require("ssl.https")
local ltn12 = require("ltn12")
local path = "/mnt/sdcard/test11.png"
snapShot(path, 0, 0, 100, 100)
mSleep(500)
local base64 = getFileBase64(path):gsub("%s", "")
local imagePrefix = "设备001"
local payload = '{"image":"' .. base64 .. '","mime_type":"image/png","filename":"test11.png","prefix":"' .. imagePrefix .. '"}'
local response = {}
local ok, status = https.request{
url = "https://服务器地址/api/images",
method = "POST",
headers = {
["Content-Type"] = "application/json",
["Content-Length"] = tostring(#payload)
},
source = ltn12.source.string(payload),
sink = ltn12.sink.table(response)
}
print(status, table.concat(response))