---
title: Data URL
slug: aura/data-url
docTags: 
createdAt: 2025-07-07T20:39:55.890Z
---

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](https://fetch.spec.whatwg.org/#data-urls).

## Atalhos

- **[Process](docId\:L5yb8U7ZUDdbLz6XUxDNA)**
- **[Create](docId\:L5yb8U7ZUDdbLz6XUxDNA)**

***

### Métodos

### Process

```lua
-- @param data String containing the Data URL.
-- @return a table containing all of the the data url parts.
dataurl.process(data)
```

```lua
-- 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

```lua
-- @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)
```

```lua
-- example usage

local data = dataurl.create("text/plain", "my text here")

-- "data:text/plain;charset=utf-8;base64,bXkgdGV4dCBoZXJl"

```
