← @mortar-kit/core

Assetsinterface

import { Assets } from '@mortar-kit/core'

interface Assets

Uploaded files: what the admin's library and pickers need. The methods marked optional are always there from createContent; an app wrapping them (in server functions) may leave them out, and the admin then hides what needs them (details, folders).

Properties

readonly maxSize?: number

The largest file upload accepts, in bytes (createContent's maxAssetSize).

list: () => Promise<Asset[]>

Every uploaded file, newest first.

upload: (file: File, details?: AssetDetails) => Promise<UploadResult>

Checks a file (type by its name's extension, size) and stores it under a fresh key, with details (e.g. the folder to put it in). Problems are returned, not thrown.

remove: (key: string) => Promise<RemoveResult>

Deletes a file by key, unless documents use it (then they are returned). Its details go with it.

update?: (key: string, details: AssetDetails) => Promise<UpdateAssetResult>

Sets a file's default title, alt text or folder. Problems are returned, not thrown.

folders?: () => Promise<AssetFolder[]>

Every folder, by name.

saveFolder?: (folder: { id?: string; name: string }) => Promise<FolderResult>

Creates a folder (no id) or renames one. Names are unique, ignoring case.

removeFolder?: (id: string) => Promise<void>

Deletes a folder; its files stay, in no folder.