@mocanvas/editor · interface
interface AssetStoreThe seam between the editor and wherever asset bytes actually live.
An app implements this to put dropped and pasted files somewhere durable — object storage, a CDN, its own upload endpoint — and to turn a stored asset back into a URL the canvas can paint. The editor never assumes anything about the transport; it only ever calls these three methods.
Only upload is required. Without resolve the editor falls back
to the asset's own props.src (see resolveAssetUrl); without
remove, deleting an asset record leaves the bytes in place.
Methods · 1
upload(asset: Asset, file: File, abortSignal?: AbortSignal): Promise<AssetUploadResult>Store the bytes for a freshly created asset and say where they landed.
Called once per file, before the asset record is written, so the returned
src is what every collaborator will see. Throw to reject the file (wrong
type, too large, quota exhausted) — the editor will not create the shape.
Properties · 2
remove?(assetIds: AssetId[]): Promise<void>Forget the bytes behind these assets. Best-effort: the records are gone either way.
resolve?(asset: Asset, context: AssetContext): Promise<string | null> | string | nullTurn a stored asset into a URL to load right now, or null when it cannot
be shown. May return a different URL per AssetContext — a thumbnail
at low zoom, the original when shouldResolveToOriginal is set.
Mentioned here
mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.