Dala.Blob (dala v0.0.2)

Copy Markdown View Source

Binary data handling via blob references.

Blobs are stored temporarily in an ETS table with a reference atom.

Examples

# Create a blob from binary data
blob_ref = Dala.Blob.create(<<1, 2, 3>>, "application/octet-stream")

# Slice a blob
sliced = Dala.Blob.slice(blob_ref, 0, 2)

# Convert to base64
base64 = Dala.Blob.to_base64(blob_ref)

# Save to file
{:ok, path} = Dala.Blob.to_file(blob_ref, "/tmp/blob.bin")

Summary

Functions

create(data, type \\ "application/octet-stream")

@spec create(binary(), String.t()) :: atom()

slice(blob_ref, start, end_pos)

@spec slice(atom(), non_neg_integer(), non_neg_integer()) :: atom()

to_base64(blob_ref)

@spec to_base64(atom()) :: String.t() | nil

to_file(blob_ref, path)

@spec to_file(atom(), String.t()) :: {:ok, String.t()} | {:error, atom()}