pub struct FileRef {
pub id: String,
pub sub: String,
pub name: String,
pub size: u64,
pub mime: String,
pub sha256: String,
pub shard: Option<u32>,
}Expand description
File reference stored as JSON in FILE columns.
Contains all metadata needed to locate and serve the file. The server stores this as a JSON string inside FILE-typed columns.
§JSON example
{
"id": "1234567890123456789",
"sub": "f0001",
"name": "document.pdf",
"size": 1048576,
"mime": "application/pdf",
"sha256": "abc123..."
}Fields§
§id: StringUnique file identifier (Snowflake ID).
sub: StringSubfolder name (e.g., "f0001", "f0002").
name: StringOriginal filename (preserved for display/download).
size: u64File size in bytes.
mime: StringMIME type (e.g., "image/png", "application/pdf").
sha256: StringSHA-256 hash of file content (hex-encoded).
shard: Option<u32>Optional shard ID for shared tables.
Implementations§
Source§impl FileRef
impl FileRef
Sourcepub fn from_json(json: &str) -> Option<Self>
pub fn from_json(json: &str) -> Option<Self>
Parse a FileRef from a raw JSON string (as stored in FILE columns).
Sourcepub fn from_json_value(value: &Value) -> Option<Self>
pub fn from_json_value(value: &Value) -> Option<Self>
Try to extract a FileRef from a serde_json::Value.
Handles both:
- A JSON string (the value is parsed as JSON)
- A JSON object (deserialized directly)
Sourcepub fn download_url(
&self,
base_url: &str,
namespace: &str,
table: &str,
) -> String
pub fn download_url( &self, base_url: &str, namespace: &str, table: &str, ) -> String
Full download URL for this file.
{base_url}/v1/files/{namespace}/{table}/{sub}/{stored_name}Sourcepub fn relative_url(&self, namespace: &str, table: &str) -> String
pub fn relative_url(&self, namespace: &str, table: &str) -> String
Relative HTTP path (no host) for this file.
/v1/files/{namespace}/{table}/{sub}/{stored_name}Sourcepub fn stored_name(&self) -> String
pub fn stored_name(&self) -> String
Stored filename on disk.
Format: {id}-{sanitized_name}.{ext} or {id}.{ext} when the
original name contains only non-ASCII characters.
Sourcepub fn relative_path(&self) -> String
pub fn relative_path(&self) -> String
Relative path within the table folder.
- User tables:
{sub}/{stored_name} - Shared tables with shard:
shard-{n}/{sub}/{stored_name}
Sourcepub fn type_description(&self) -> String
pub fn type_description(&self) -> String
Human-readable file type description.
Examples: "Image", "Video", "PDF Document", "PNG File".
Sourcepub fn format_size(&self) -> String
pub fn format_size(&self) -> String
Format file size in human-readable units.
Examples: "0 B", "256 KB", "1.5 MB", "3.2 GB".