interface IStorage
Since 0.1.0

Object storage abstraction.

Examples

Example 1

const storage = ctx.services.get<IStorage>(CAPABILITIES.STORAGE);
await storage.put('uploads/photo.jpg', bytes);
const url = await storage.getSignedUrl('uploads/photo.jpg', { expiresIn: 3600 });

Methods

put(
path: string,
data: Uint8Array,
): Promise<void>

Stores an object.

get(path: string): Promise<Uint8Array>

Retrieves an object.

delete(path: string): Promise<boolean>

Deletes an object.

exists(path: string): Promise<boolean>

Reports whether an object exists.

getSignedUrl(
path: string,
): Promise<string>

Creates a time-limited URL granting direct access to an object.

Since 0.2.0
optional
getStream(path: string): Promise<ReadableStream<Uint8Array>>

Retrieves an object as a streaming body for zero-copy downloads.

Providers that support native streaming (S3, GCS, Azure) return a live stream; others fall back to buffering the entire object into a one-chunk stream via get.

When omitted on the provider, the service wraps get in a one-chunk ReadableStream. Absent objects throw (mirroring get).

Usage

import { type IStorage } from "common/src/index.ts";