API / @aionbuilders/nabu

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

Parameters of insertMediaFromFile
ParameterTypeDescription
nabuNabun/a
typestringn/a
fileFilen/a

Returns

Promise<void>

Source: src/lib/blocks/media/media.helpers.js:12