insertMediaFromFile
Function Stability: stable
Insert a media block of type from a local File. The block appears at once (pending, with a local preview), the bytes
are hashed and written to the local store (ADR 014), then the block gets its nabu-asset:sha256-… ref: ready, or — with a
host (files.onBeforePersist) — still pending while the background upload runs (block.progress, block.retry(),
block.cancel()); the ref never changes afterwards. A file over files.maxFileSize is refused: the block is created
rejected, with no ref and a readable reason.
Signature
TypeScript
import { insertMediaFromFile } from '@aionbuilders/nabu';TypeScript
function insertMediaFromFile(nabu: Nabu, type: string, file: File): Promise<void>Parameters
| Parameter | Type | Description |
|---|---|---|
nabu | Nabu | n/a |
type | string | n/a |
file | File | n/a |
Returns
Promise<void>
Source: src/lib/blocks/media/media.helpers.js:12