Object Storage
DocsObject storage is for files and blobs, not small JSON records. This demo reads linked AWS_* bucket env with @agentuity/storage, then uses Bun's S3Client only for temporary share URLs. Use it for files such as uploads, reports, images, and generated artifacts when the data is a file people or systems need to download. For exact-key JSON state, see KV storage.
Document:hello.txt
Files (0)
No files yet. Click "Load Sample Data" to add a sample file.
Reference Code
import { S3Client } from "bun";
import { bucketConfigFromEnv, createS3Client } from "@agentuity/storage";
import { resolveEndpoint } from "@agentuity/storage/types";
// Reads the linked AWS_* bucket env.
const bucket = bucketConfigFromEnv();
const storage = createS3Client(bucket);
const key = "reports/demo-" + crypto.randomUUID() + ".txt";
const body = "Generated at " + new Date().toISOString();
// Portable SDK path: works in Bun and Node.js.
await storage.write(key, body, {
type: "text/plain",
});
const file = storage.file(key);
const text = await file.text();
const stat = await storage.stat(key);
const listing = await storage.list({ prefix: "reports/", maxKeys: 10 });
// Bun-only presign option today: S3Client is Bun's client class.
const bunStorage = new S3Client({
endpoint: resolveEndpoint(bucket),
accessKeyId: bucket.access_key,
secretAccessKey: bucket.secret_key,
region: bucket.region ?? "auto",
virtualHostedStyle: true,
});
const downloadUrl = bunStorage.presign(key, {
method: "GET",
expiresIn: 60 * 15,
});
// Node.js presign option:
// Use @aws-sdk/s3-request-presigner with @aws-sdk/client-s3.
// @agentuity/storage does not expose storage.presign() yet.
//
// Delete the object after the share URL no longer needs to work:
// await storage.delete(key);
export const report = {
key,
text,
bytes: stat.size,
filesListed: listing.contents.length,
downloadUrl,
};Ready
Output will appear here...