UNPKG

@jrmc/adonis-attachment

Version:

Turn any field on your Lucid model to an attachment data type

41 lines 2.39 kB
/** * @jrmc/adonis-attachment * * @license MIT * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr> */ import type { DriveService, SignedURLOptions } from '@adonisjs/drive/types'; import type { MultipartFile } from '@adonisjs/core/bodyparser'; import type { AttachmentAttributes, AttachmentBase, Attachment as AttachmentType } from './types/attachment.js'; import type { ResolvedAttachmentConfig } from './define_config.js'; import { DeferQueue } from '@poppinss/defer'; import Converter from './converters/converter.js'; export declare class AttachmentManager<KnownConverters extends Record<string, Converter>> { #private; queue: DeferQueue; constructor(config: ResolvedAttachmentConfig<KnownConverters>, drive: DriveService); createFromDbResponse(response?: string | JSON): AttachmentType | null; createFromFile(input: MultipartFile): Promise<AttachmentType>; createFromFiles(inputs: MultipartFile[]): Promise<(AttachmentBase & { originalName: string; variants?: import("./types/attachment.js").Variant[]; moveFileForDelete(): Promise<void>; rollbackMoveFileForDelete(): Promise<void>; createVariant(key: string, input: import("./types/input.js").Input): Promise<import("./types/attachment.js").Variant>; getVariant(variantName: string): import("./types/attachment.js").Variant | undefined; getUrl(variantName?: string): Promise<string>; getSignedUrl(variantNameOrOptions?: string | SignedURLOptions, signedUrlOptions?: SignedURLOptions): Promise<string>; toObject(): AttachmentAttributes; })[]>; createFromPath(input: string, name?: string): Promise<AttachmentType>; createFromBuffer(input: Buffer, name?: string): Promise<AttachmentType>; createFromBase64(input: string, name?: string): Promise<AttachmentType>; createFromUrl(input: URL, name?: string): Promise<AttachmentType>; createFromStream(stream: NodeJS.ReadableStream, name?: string): Promise<AttachmentType>; getConverter(key: string): Promise<void | Converter>; computeUrl(attachment: AttachmentType | AttachmentBase, signedUrlOptions?: SignedURLOptions): Promise<void>; preComputeUrl(attachment: AttachmentType): Promise<void>; write(attachment: AttachmentBase): Promise<void>; remove(attachment: AttachmentBase): Promise<void>; } //# sourceMappingURL=attachment_manager.d.ts.map