NAME
Net::Blossom::BlobDescriptor - Blossom blob descriptor value object
SYNOPSIS
use Net::Blossom::BlobDescriptor;
my $blob = Net::Blossom::BlobDescriptor->from_hash({
url => 'https://cdn.example.com/file',
sha256 => $sha256,
size => 1234,
type => 'application/octet-stream',
uploaded => 1725105921,
});
my $hash = $blob->to_hash;
DESCRIPTION
Net::Blossom::BlobDescriptor represents the JSON descriptor returned by Blossom upload, mirror, media, and list endpoints.
The standard descriptor fields are exposed as accessors. Unknown JSON fields are preserved in extra so callers do not lose extension data.
CONSTRUCTORS
new
my $blob = Net::Blossom::BlobDescriptor->new(%args);
Creates a descriptor. Required arguments are url, sha256, size, type, and uploaded. Required fields must be scalar values. sha256 must be lowercase 64-character hex. size and uploaded must be non-negative integers.
Optional nip94 must be an array reference of NIP-94 tag arrays. Optional extra must be a hash reference and must not contain standard descriptor field names.
Unknown arguments or invalid values croak.
from_hash
my $blob = Net::Blossom::BlobDescriptor->from_hash($hashref);
Builds a descriptor from a decoded JSON hash reference. Unknown fields are moved into extra.
ACCESSORS
url
Returns the blob URL.
sha256
Returns the lowercase SHA-256 hash.
size
Returns the blob size in bytes.
type
Returns the media type.
uploaded
Returns the upload timestamp.
nip94
Returns the optional NIP-94 tag array reference.
extra
Returns the hash reference containing extension fields.
METHODS
get
my $value = $blob->get($field);
Returns a standard descriptor field or an extension field from extra.
to_hash
my $hash = $blob->to_hash;
Returns a hash reference suitable for JSON encoding. Standard fields are included with numeric size and uploaded values, extension fields are preserved, and nip94 is included when present.