Data URL
Utilizada para embutir pequenos arquivos diretamente em documentos, representando dados como uma string codificada em Base64. Segue o formato data:[<tipo MIME>][;base64],<dados> de acordo com o Fetch Standard.
Atalhos
Métodos
Process
-- @param data String containing the Data URL.
-- @return a table containing all of the the data url parts.
dataurl.process(data)-- example usage
local result = dataurl.process("data:text/plain;charset=iso-8859-7,%eb%fc%e3%ef%f2#fragment-url-here")
local body = result.body
local mimetype = result.mime.full
--[[
{
body = "�����",
fragment = "fragment-url-here",
mime = {
full = "text/plain;charset=iso-8859-7",
parameters = {
charset = "iso-8859-7"
},
subtype = "plain",
type = "text"
}
}
--]]Create
-- @param mimetype String containing the mimetype.
-- @param bytes String containing the bytes of the file.
-- @return a string containing the dataurl.
dataurl.create(mimetype, bytes)-- example usage
local data = dataurl.create("text/plain", "my text here")
-- "data:text/plain;charset=utf-8;base64,bXkgdGV4dCBoZXJl"