Skip to content

Latest commit

 

History

History
96 lines (67 loc) · 2.11 KB

File metadata and controls

96 lines (67 loc) · 2.11 KB

Images

How images are stored and served in Eventky.

Architecture

Images use Pubky's two-record pattern:

  1. Blob — Raw binary data stored at /pub/pubky.app/blobs/:id
  2. File — JSON metadata referencing the blob at /pub/pubky.app/files/:id

Storage (Write Path)

Use uploadImageFile() to upload images:

import { uploadImageFile } from "@/lib/pubky/files";

const fileUri = await uploadImageFile(session, userId, file);
// Returns: pubky://userId/pub/pubky.app/files/fileId

This function:

  1. Reads file as Uint8Array
  2. Creates blob record via PubkySpecsBuilder.createBlob()
  3. Uploads raw bytes to homeserver
  4. Creates file metadata via PubkySpecsBuilder.createFile()
  5. Uploads file JSON to homeserver

Deletion

import { deleteImageFile } from "@/lib/pubky/files";

await deleteImageFile(session, fileUri);

Deletes both blob and file records.

Display (Read Path)

Images are served through Nexus, which:

  • Indexes uploaded files
  • Generates size variants
  • Caches for performance

URL Helpers

import { getPubkyImageUrl, getPubkyAvatarUrl } from "@/lib/pubky/utils";

// Event/calendar images
getPubkyImageUrl(fileUri, "main");  // Full size
getPubkyImageUrl(fileUri, "feed");  // Thumbnail

// User avatars
getPubkyAvatarUrl(userUri);

Variants

Variant Use Case Size
main Full display, modals Original/large
feed Lists, thumbnails Smaller

URL Format

https://nexus.eventky.app/file/{userId}/{fileId}/{variant}
https://nexus.eventky.app/avatar/{userId}

In Event/Calendar Records

Images are referenced by their file URI:

// Event with image
const event = {
    // ...
    image_uri: "pubky://userId/pub/pubky.app/files/abc123"
};

// Calendar with image  
const calendar = {
    // ...
    image_uri: "pubky://userId/pub/pubky.app/files/xyz789"
};

Related