fileSystem.write
Text as UTF-8, or an ArrayBuffer's bytes as they are.
Usage
Write a note and download a photo
import { Image, fileSystem } from 'kuito';
const url = 'https://example.com/photo.jpg';
const notes = fileSystem.documents + 'notes.txt';
await fileSystem.write(notes, 'hello');
await fileSystem.write(notes, ' world', { append: true });
await fileSystem.read(notes); // 'hello world'
await fileSystem.readBytes(notes, { position: 6, length: 5 }); // an ArrayBuffer of 'world'
await fileSystem.info(notes); // { exists: true, uri, isDirectory: false, size: 11, lastModified }
await fileSystem.delete(notes);
const photo = fileSystem.download(url, fileSystem.cache + 'photo.jpg', {
headers: { Authorization: 'Bearer …' },
onProgress: ({ bytes, total }) => console.log(bytes, total),
});
const { uri } = await photo; // or photo.cancel()
export const Photo = () => <Image src={{ uri }} />;Signatures
(uri: string, contents: string | ArrayBuffer, options?: WriteOptions): Promise<void>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
uri | string | Yes | — |
contents | string | ArrayBuffer | Yes | — |
options | WriteOptions | No | — Default: {} |
Returns
Promise<void>
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.