Enhance DocumentSchema and MinioService to support document folder creation. Update document creation logic to include folder setup in Minio after document creation. Refactor createDocumentFolder method to initialize a default page in the document folder. This improves document management and organization within the Minio storage system.

This commit is contained in:
2024-11-28 20:09:37 +07:00
parent e546c348cc
commit abb7e38df3
3 changed files with 29 additions and 42 deletions

View File

@@ -81,9 +81,15 @@ export class MinioService {
async deleteFile(id: string, category: string) {
return await this.minioClient.removeObject(this.configService.get('BUCKET_NAME') ?? 'epess', `${category}/${id}`)
}
// create a folder for a document pattern epess/documents/<id>/<page>
// create a folder for a document pattern epess/documents/<id>/<page> and add page 0 to default
async createDocumentFolder(id: string) {
return await this.minioClient.putObject(this.configService.get('BUCKET_NAME') ?? 'epess', `documents/${id}`, '')
const emptyDelta = JSON.stringify(new Delta().insert('\n'))
const result = await this.minioClient.putObject(
this.configService.get('BUCKET_NAME') ?? 'epess',
`documents/${id}/0`,
emptyDelta,
)
return result
}
async upsertDocumentPage(id: string, page: number, delta: Delta) {