blob

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package blob implements JMAP Blob Management (RFC 9404).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register()

Register registers the Capability and all Blob methods with the jmap package. Must be called before using blob types.

Types

type Capability

type Capability struct {
	// MaxSizeBlobSet is the maximum total size of a Blob/upload request.
	MaxSizeBlobSet uint64 `json:"maxSizeBlobSet"`

	// MaxDataSources is the maximum number of DataSourceObjects in a
	// single create.
	MaxDataSources uint64 `json:"maxDataSources"`

	// SupportedTypeNames lists the type names that support blob lookup.
	SupportedTypeNames []string `json:"supportedTypeNames"`

	// SupportedDigestAlgorithms lists the digest algorithms the server
	// supports for Blob/get.
	SupportedDigestAlgorithms []string `json:"supportedDigestAlgorithms"`
}

Capability represents the urn:ietf:params:jmap:blob capability (RFC 9404 Section 3).

func (*Capability) New

func (c *Capability) New() jmap.Capability

New implements jmap.Capability.

func (*Capability) URI

func (c *Capability) URI() jmap.URI

URI implements jmap.Capability.

type Data

type Data struct {
	// ID is the blob identifier.
	ID jmap.ID `json:"id"`

	// Data is the base64-encoded blob content.
	Data *string `json:"data:asBase64,omitempty"`

	// IsEncodingProblem indicates whether the data could not be
	// faithfully represented as base64.
	IsEncodingProblem *bool `json:"isEncodingProblem,omitempty"`

	// IsTruncated indicates whether the data was truncated.
	IsTruncated *bool `json:"isTruncated,omitempty"`

	// Size is the total size of the blob in octets.
	Size *uint64 `json:"size,omitempty"`

	// Digest is the digest of the blob in the requested algorithm.
	Digest *string `json:"digest,omitempty"`
}

Data represents data returned for a single blob by Blob/get (RFC 9404 Section 4.2).

type DataSource

type DataSource struct {
	// DataAsBase64 is base64-encoded binary data.
	DataAsBase64 *string `json:"data:asBase64,omitempty"`

	// DataAsText is UTF-8 text data.
	DataAsText *string `json:"data:asText,omitempty"`

	// SourceBlobID references an existing blob to copy data from.
	SourceBlobID *jmap.ID `json:"blobId,omitempty"`

	// Offset is the byte offset into the source blob.
	Offset *uint64 `json:"offset,omitempty"`

	// Length is the number of bytes to copy from the source blob.
	Length *uint64 `json:"length,omitempty"`
}

DataSource is a single data source within a DataSourceObject.

type DataSourceObject

type DataSourceObject struct {
	// Data is the list of data sources to concatenate.
	Data []DataSource `json:"data"`

	// Type is the optional media type of the resulting blob.
	Type *string `json:"type,omitempty"`
}

DataSourceObject describes the data sources to concatenate for a blob (RFC 9404 Section 4.1).

type Get

type Get struct {
	// AccountID is the account to retrieve blobs from.
	AccountID jmap.ID `json:"accountId"`

	// IDs is the list of blob identifiers to retrieve.
	IDs []jmap.ID `json:"ids"`

	// Properties lists the properties to return for each blob.
	Properties []string `json:"properties,omitempty"`

	// Offset is the byte offset to start reading from.
	Offset *uint64 `json:"offset,omitempty"`

	// Length is the number of bytes to return.
	Length *uint64 `json:"length,omitempty"`

	// DigestAlgorithm is the digest algorithm to use for computing a
	// digest of the blob data.
	DigestAlgorithm *string `json:"digestAlgorithm,omitempty"`
}

Get is the Blob/get method (RFC 9404 Section 4.2).

func (*Get) Name

func (m *Get) Name() string

Name implements jmap.Method.

func (*Get) Requires

func (m *Get) Requires() []jmap.URI

Requires implements jmap.Method.

type GetResponse

type GetResponse struct {
	// AccountID is the account the blobs were retrieved from.
	AccountID jmap.ID `json:"accountId"`

	// List contains the data for each found blob.
	List []*Data `json:"list,omitempty"`

	// NotFound lists blob IDs that were not found.
	NotFound []jmap.ID `json:"notFound,omitempty"`
}

GetResponse is the response to Blob/get (RFC 9404 Section 4.2).

func (*GetResponse) Name

func (r *GetResponse) Name() string

Name implements jmap.MethodResponse.

type Info

type Info struct {
	// ID is the blob identifier.
	ID jmap.ID `json:"id"`

	// Type is the media type of the blob.
	Type *string `json:"type,omitempty"`

	// Size is the size of the blob in octets.
	Size uint64 `json:"size"`
}

Info describes a successfully created blob (RFC 9404 Section 4.1).

type Lookup

type Lookup struct {
	// AccountID is the account to search in.
	AccountID jmap.ID `json:"accountId"`

	// TypeNames lists the object types to search for blob references.
	TypeNames []string `json:"typeNames"`

	// IDs is the list of blob identifiers to look up.
	IDs []jmap.ID `json:"ids"`
}

Lookup is the Blob/lookup method (RFC 9404 Section 4.3).

func (*Lookup) Name

func (m *Lookup) Name() string

Name implements jmap.Method.

func (*Lookup) Requires

func (m *Lookup) Requires() []jmap.URI

Requires implements jmap.Method.

type LookupResponse

type LookupResponse struct {
	// AccountID is the account that was searched.
	AccountID jmap.ID `json:"accountId"`

	// List contains the lookup results for each found blob.
	List []*LookupResult `json:"list,omitempty"`

	// NotFound lists blob IDs that were not found.
	NotFound []jmap.ID `json:"notFound,omitempty"`
}

LookupResponse is the response to Blob/lookup (RFC 9404 Section 4.3).

func (*LookupResponse) Name

func (r *LookupResponse) Name() string

Name implements jmap.MethodResponse.

type LookupResult

type LookupResult struct {
	// ID is the blob identifier.
	ID jmap.ID `json:"id"`

	// MatchedIDs maps type names to the IDs of objects that reference
	// this blob.
	MatchedIDs map[string][]jmap.ID `json:"matchedIds"`
}

LookupResult contains the matched IDs for a single blob (RFC 9404 Section 4.3).

type Upload

type Upload struct {
	// AccountID is the account to upload the blob to.
	AccountID jmap.ID `json:"accountId"`

	// Create maps creation IDs to DataSourceObjects describing the blobs
	// to create.
	Create map[jmap.ID]*DataSourceObject `json:"create"`
}

Upload is the Blob/upload method (RFC 9404 Section 4.1).

func (*Upload) Name

func (m *Upload) Name() string

Name implements jmap.Method.

func (*Upload) Requires

func (m *Upload) Requires() []jmap.URI

Requires implements jmap.Method.

type UploadResponse

type UploadResponse struct {
	// AccountID is the account the blobs were created in.
	AccountID jmap.ID `json:"accountId"`

	// Created maps creation IDs to the successfully created Info.
	Created map[jmap.ID]*Info `json:"created,omitempty"`

	// NotCreated maps creation IDs to SetErrors for failed creations.
	NotCreated map[jmap.ID]*jmap.SetError `json:"notCreated,omitempty"`
}

UploadResponse is the response to Blob/upload (RFC 9404 Section 4.1).

func (*UploadResponse) Name

func (r *UploadResponse) Name() string

Name implements jmap.MethodResponse.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL