StoredFile
TypeWhat a write returns: the stored key, its URL, and a signed-link method.
The record a write returns. It carries the object's key, a stable on-domain url for an <img> or <a>, the size and content type, and shareUrl() for minting a signed link to a private file. Hand url to the frontend directly rather than reading the bytes yourself.
StoredFile.ts
interface StoredFile { key: string url: string size?: number contentType?: string updatedAt?: number shareUrl(options?): Promise<string> }
Fields
key
string
The object's key within the store.
url
string
Stable, on-domain URL for an <img>, <a>, or fetch.
size
number
Size in bytes.
contentType
string
The stored content type.
updatedAt
number
Unix epoch milliseconds of the last write.
shareUrl
(options?)
Mint an expiring signed link to a private file.
Use the returned file
const file = await Reports.put(pdf, { contentType: 'application/pdf' }); return { url: file.url };