UNPKG

lynx-framework

Version:

lynx is a NodeJS framework for Web Development, based on decorators and the async/await support.

59 lines (58 loc) 2.23 kB
import BaseEntity from "./base.entity"; import User from "./user.entity"; export interface ResizeConfig { rotate: number; scaleX: number; scaleY: number; x: number; y: number; width: number; height: number; } export default class Media extends BaseEntity { hiddenFields: string[]; id: number; originalName: string; slug: string; private is_directory; get isDirectory(): boolean; set isDirectory(value: boolean); mimetype: string; size: number; fileName: string; path: string; parent: Media; _children: Media[]; owner: User; width: number; height: number; get children(): Promise<Media[]>; remove(): Promise<this>; /** * Create a cropped image starting of the current. * The image will be placed in the same directory as the original. * @param config: The configuration object containing the crop parameters * @return a promise with the new @type Media */ resizeToNewEntity(config: ResizeConfig): Promise<Media>; /** * Generate a new MediaEntity from an uploaded file using the Multer library * @param uploadMedia the multer File * @param user the user performing the request (aka the onwer of the file) * @param directory the (optional) virtual parent directory */ static persist(uploadMedia: Express.Multer.File, user: User, directory?: Media): Promise<Media>; /** * Generate a new MediaEntity from a local temporary file * @param originalName the original name of the file * @param path the temporary path of the file * @param user the user perfrming the request (aka the owner of the file) * @param directory the (optional) virtual parent directory */ static persistTempFile(originalName: string, path: string, user: User, directory?: Media): Promise<Media>; static mkdir(name: string, user?: User, directory?: Media | null): Promise<Media>; static getFolder(path: string): Promise<Media | undefined>; static findBySlug(slug: string): Promise<Media | undefined>; static findBySlugOrId(key: string): Promise<Media | undefined>; static findOneWithParent(id: number): Promise<Media | undefined>; }