KalamFileRef class

Type-safe file reference for KalamDB FILE columns.

Provides parsing from JSON, download URL generation, and metadata access. URL/path helpers delegate to the shared Rust link-common FileRef model.

final ref = KalamFileRef.tryParse(row['attachment']);
if (ref != null) {
  final url = ref.getDownloadUrl('http://localhost:18080', 'default', 'messages');
  print('${ref.name} (${ref.formatSize()})');
}
Implemented types

Constructors

KalamFileRef({required String id, required String sub, required String name, required int size, required String mime, required String sha256, int? shard})
const
KalamFileRef.fromBridge(DartFileRef ref)
Create from a bridge-generated `DartFileRef`.
factory
KalamFileRef.fromData(KalamFileRefData data)
Create from a KalamFileRefData or a raw map.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
id → String
Unique file identifier (Snowflake ID).
final
isAudio → bool
Whether this is an audio file (based on MIME type).
no setter
isImage → bool
Whether this is an image file (based on MIME type).
no setter
isVideo → bool
Whether this is a video file (based on MIME type).
no setter
mime → String
MIME type (e.g. "image/png", "application/pdf").
final
name → String
Original filename (preserved for display / download).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sha256 → String
SHA-256 hash of file content (hex-encoded).
final
shard → int?
Optional shard ID for shared tables.
final
size → int
File size in bytes.
final
sub → String
Subfolder name (e.g. "f0001", "f0002").
final

Methods

formatSize() → String
Format size in human-readable form (e.g. "1.5 MB").
getDownloadUrl(String baseUrl, String namespace, String table) → String
Generate a download URL for this file.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
relativePath() → String
Relative storage path within the table folder.
relativeUrl(String namespace, String table) → String
Relative HTTP download path for this file.
storedName() → String
Stored filename used by the file service: {id}-{sanitized-name}.{ext}.
toBridge() → DartFileRef
toJson() → String
Serialize back to a JSON string.
toMap() → Map<String, dynamic>
Convert to a plain map.
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

fromJson(String? json) → KalamFileRef?
Parse from a JSON string (as stored in FILE columns).
tryParse(dynamic value) → KalamFileRef?
Parse from an unknown value — handles JSON string, Map, or null.