Asset class

A downloadable file attached to a Release — a tarball, an installer, a checksum file, a signature.

The record is metadata only: the bytes live in an ObjectStorage behind whichever provider (the hub itself, or one of the organization's nodes) holds them, addressed by storageKey. That separation is what lets one release's assets be served from several nodes, and what lets the storage backend change from a local directory to S3 without touching the registry.

sha256 is not optional. An update system that hands a client bytes it cannot verify is an update system that can be turned into a malware delivery channel by anyone who can write to the object store, so the checksum is computed on upload and checked on download.

Available extensions
Annotations
  • @immutable
  • @JsonSerializable.new(explicitToJson: true)

Constructors

Asset({required String id, required String releaseId, required String packageId, required String organizationId, required String name, required String storageKey, String contentType = 'application/octet-stream', required int sizeBytes, required String sha256, String? platform, String? kind, int downloadCount = 0, required DateTime createdAt, Map<String, String> metadata = const {}})
Creates an asset record. metadata is copied into an unmodifiable map.
Asset.fromJson(Map<String, dynamic> json)
Parses an asset from a JSON map.
factory

Properties

contentType String
MIME type (application/gzip), used for the download content-type.
final
createdAt DateTime
When the asset was uploaded (UTC).
final
downloadCount int
How many times this asset has been downloaded.
final
downloadHeaders Map<String, String>

Available on Asset, provided by the AssetResponseHeaders extension

The headers a download of this asset should carry.
no setter
hashCode int
The hash code for this object.
no setteroverride
id String
Stable, opaque identifier assigned at upload.
final
kind String?
A free-form kind tag (installer, archive, checksums, signature) letting a client pick the right artifact among several for one platform.
final
metadata Map<String, String>
Arbitrary application-defined key/value pairs.
final
name String
The filename clients download it as (omnyagent-linux-x64.tar.gz). Unique within the release; validated by Names.requireFilename.
final
organizationId String
The owning organization's Organization.id, denormalised for routing.
final
packageId String
The owning package's Package.id, denormalised so a download can be recorded and routed without loading the release.
final
platform String?
The target platform (linux-x64, macos-arm64, windows-x64), or null for a platform-independent artifact.
final
releaseId String
The owning release's Release.id.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sha256 String
Lower-case hex SHA-256 of the content, computed while uploading.
final
sizeBytes int
Size in bytes, verified against the uploaded stream.
final
storageKey String
The key the bytes are stored under in the object store.
final

Methods

copyWith({String? contentType, String? platform, String? kind, int? downloadCount, Map<String, String>? metadata}) Asset
Returns a copy with the mutable fields replaced.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Serialises the asset to a JSON map.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override