lib/common/file/file.service.ts
Service for managing files, including uploading, finding, and removing files.
Methods |
|
constructor(logger: Logger, fileRep: Repository<FileEntity>, cacheService: CacheService, metadataService: FileMd)
|
|||||||||||||||
Defined in lib/common/file/file.service.ts:44
|
|||||||||||||||
Parameters :
|
Private createBasicFindQb |
createBasicFindQb()
|
Defined in lib/common/file/file.service.ts:226
|
Private helper method to create a query builder for finding files with their related entities.
Returns :
any
A query builder instance for finding files. |
Private Async createFileDirectory | ||||||||||||
createFileDirectory(isPublic: boolean, entityId: string)
|
||||||||||||
Defined in lib/common/file/file.service.ts:256
|
||||||||||||
Private helper method to create a file directory for the specified public/private status and entity ID.
Parameters :
Returns :
Promise<string>
A promise that resolves to the created directory path as a string. |
Private Async createFileEntity | ||||||||
createFileEntity(isPublic: boolean)
|
||||||||
Defined in lib/common/file/file.service.ts:273
|
||||||||
Private helper method to create a new FileEntity with the specified public/private status.
Parameters :
Returns :
unknown
A promise that resolves to the created FileEntity. |
Async createOrUpdateFile | |||||||||||||||||||||||||||||||||||
createOrUpdateFile(file: Buffer, extension: string, isPublic, code?: string, existedEntityId?: number, name?: string)
|
|||||||||||||||||||||||||||||||||||
Inherited from
FileManager
|
|||||||||||||||||||||||||||||||||||
Defined in
FileManager:66
|
|||||||||||||||||||||||||||||||||||
Uploads a file and saves it to the specified directory (public or private). Also creates a FileEntity and saves the file's metadata in the database.
Parameters :
Returns :
Promise<FileEntity>
A promise that resolves to the created FileEntity. |
Async findByCode | ||||||||
findByCode(code: string)
|
||||||||
Inherited from
FileManager
|
||||||||
Defined in
FileManager:148
|
||||||||
Finds a file entity by code.
Parameters :
Returns :
Promise<FileEntity>
The found file entity. |
Async findFileById | |||||||||||||||
findFileById(id: number, isPublic: boolean)
|
|||||||||||||||
Inherited from
FileManager
|
|||||||||||||||
Defined in
FileManager:131
|
|||||||||||||||
Private helper method to find a file by its ID and public/private status.
Parameters :
Returns :
unknown
A promise that resolves to the found FileEntity. |
Async findPrivateById | ||||||||
findPrivateById(id: number)
|
||||||||
Inherited from
FileManager
|
||||||||
Defined in
FileManager:168
|
||||||||
Finds a private file by its ID.
Parameters :
Returns :
Promise<FileEntity>
A promise that resolves to the found FileEntity. |
Async findPublicById | ||||||||
findPublicById(id: number)
|
||||||||
Inherited from
FileManager
|
||||||||
Defined in
FileManager:159
|
||||||||
Finds a public file by its ID.
Parameters :
Returns :
Promise<FileEntity>
A promise that resolves to the found FileEntity. |
Async getFilePath | ||||||||
getFilePath(file: File)
|
||||||||
Inherited from
FileManager
|
||||||||
Defined in
FileManager:177
|
||||||||
Constructs the full file path for the given File object.
Parameters :
Returns :
Promise<string>
The full file path as a string. |
Private Async getPrivateDir |
getPrivateDir()
|
Defined in lib/common/file/file.service.ts:292
|
Retrieves the private directory path stored in configuration.
Returns :
unknown
A promise that resolves to the normalized private directory path. |
Private Async getPublicDir |
getPublicDir()
|
Defined in lib/common/file/file.service.ts:283
|
Retrieves the public directory path stored in configuration.
Returns :
unknown
A promise that resolves to the normalized public directory path. |
Async remove | ||||||||
remove(id: number)
|
||||||||
Inherited from
FileManager
|
||||||||
Defined in
FileManager:187
|
||||||||
Removes a file by its ID and deletes its corresponding directory.
Parameters :
Returns :
Promise<FileEntity>
A promise that resolves to the removed FileEntity. |