Utilização

Pick a photo and hand its local file to an upload function.

tsx
// Pick a photo and hand its local file to an upload function.
import { mediaPicker, type MediaAsset, type MediaType } from 'kuito';

export async function choosePhoto(upload: (asset: MediaAsset) => Promise<void>) {
  const mediaTypes: MediaType[] = ['images'];
  const result = await mediaPicker.pick({ mediaTypes });
  if (!result.canceled && result.assets[0]) await upload(result.assets[0]);
}

Declaração do tipo

ts
export type MediaAsset = PickedAsset;

Membros 8

NomeTipoObrigatórioDescrição
uristringSimA file:// URI in the app's cache directory, for <Image source> and fileSystem.
widthnumberSimIn pixels, as displayed: orientation is already applied.
heightnumberSim—
typeMediaAssetTypeSim—
mimeTypestringSim—
fileNamestringSimThe name the user's library knows it by, when it has one.
fileSizenumberSimIn bytes, of the file at uri.
durationnumberNãoVideos only: the length in milliseconds.
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.