# blob

> Package blob defines references to content stored outside the session log, such as large tool outputs, images and oversized provider payloads.

<!-- Generated from the Go source of github.com/barevoidco/zelk/core/blob (cmd/zelk/internal/reference TestReferenceGoAPI). Don't edit: change the code, then run make reference. -->

```go
import "github.com/barevoidco/zelk/core/blob"
```

Package blob defines references to content stored outside the session log, such as large tool outputs, images and oversized provider payloads.

A [Ref](/reference/go/blob/#ref) names content by its SHA-256 digest, so a reference can never silently point at different bytes. Stores write and sync a blob before any event that refers to it. The package sits below both history and event so that history items and event payloads can refer to blobs without importing each other.


## Digest

```go
func Digest(data []byte) string
```

Digest returns the digest of data in the form [Ref](/reference/go/blob/#ref) uses.


## FromName

```go
func FromName(name string) (digest string, ok bool)
```

FromName returns the digest of the blob a name refers to. A model reads a saved output with Read by the name "blob:" and its digest; ok is false for any other string, which names a file, and for a name with a malformed digest, which no blob can have. A name is a reference, not a path: a host that checks paths must tell the two apart before it checks one.


## ValidateDigest

```go
func ValidateDigest(d string) error
```

ValidateDigest reports whether d is a digest in the form [Ref](/reference/go/blob/#ref) uses.


## Ref

```go
type Ref struct {
	// Digest is "sha256:" followed by 64 lowercase hex digits.
	Digest    string `json:"digest"`
	Size      int64  `json:"size"`
	MediaType string `json:"media_type"`
}
```

Ref refers to content stored outside the log.


### NewRef

```go
func NewRef(data []byte, mediaType string) Ref
```

NewRef returns the reference for data with the given media type.


### Ref.Validate

```go
func (r Ref) Validate() error
```

Validate reports whether the reference is well formed.
