将获取到的base64字节流,保存为图片文件,源码如下:
local bs = "base64图片编码后数据"
这里要注意,原始数据中是jpg,还是png
bs = string.gsub(bs,"data:image/png;base64,","")
或者:
bs = string.gsub(bs,"data:image/jpg;base64,","")
local ff = base64.decode(bs)
local file = io.open("a.png", "wb")
file:write(ff)
file:close()