histoire
Version:
A fast story book powered by Vite
43 lines • 1.79 kB
TypeScript
import type { UiCommentAttachment } from '@histoire/shared';
/** Largest file accepted for one comment attachment. */
export declare const ATTACHMENT_BYTES: number;
/**
* Detects an image type from its leading bytes.
* @param bytes File content.
*/
export declare function imageType(bytes: Uint8Array): string | undefined;
/**
* Stores one uploaded file beneath `.histoire/attachments` with an exclusive generated name.
* @param root Project root.
* @param name Browser-provided file name.
* @param declared Browser-provided media type.
* @param bytes File content.
*/
export declare function saveAttachment(root: string, name: string, declared: string, bytes: Uint8Array): Promise<UiCommentAttachment>;
/**
* Reads one stored attachment by generated name for thumbnails and downloads.
* @param root Project root.
* @param name Generated stored name.
*/
export declare function readAttachment(root: string, name: string): Promise<{
bytes: Uint8Array;
mimeType: string;
} | undefined>;
/**
* Stored name of a project-relative attachment path, if it is a valid generated path.
* @param path Project-relative path.
*/
export declare function attachmentName(path: string): string | undefined;
/**
* Whether a client-referenced attachment matches a stored regular file.
* @param root Project root.
* @param attachment Referenced attachment.
*/
export declare function attachmentExists(root: string, attachment: UiCommentAttachment): Promise<boolean>;
/**
* Deletes stored files no longer referenced by any comment; invalid paths are ignored.
* @param root Project root.
* @param paths Project-relative attachment paths.
*/
export declare function removeAttachments(root: string, paths: readonly string[]): Promise<void>;
//# sourceMappingURL=attachments.d.ts.map