Enhance DocumentSchema and MinioService for improved error handling and functionality. Update page index validation to check for undefined or null values. Introduce total page count retrieval in DocumentSchema and adjust senderId handling. Refactor MinioService to correctly read and parse document pages, ensuring robust object management. This update improves clarity and reliability in document synchronization processes.
This commit is contained in:
@@ -94,20 +94,27 @@ export class MinioService {
|
||||
)
|
||||
}
|
||||
async getDocumentPage(id: string, page: number) {
|
||||
const delta = (await this.minioClient.getObject(
|
||||
const delta = await this.minioClient.getObject(
|
||||
this.configService.get('BUCKET_NAME') ?? 'epess',
|
||||
`documents/${id}/${page}`,
|
||||
)) as unknown as Delta
|
||||
return delta
|
||||
)
|
||||
const buffer = await delta.read()
|
||||
return JSON.parse(buffer.toString())
|
||||
}
|
||||
async countDocumentPages(id: string): Promise<number> {
|
||||
return new Promise<number>((resolve, reject) => {
|
||||
const stream = this.minioClient.listObjects(this.configService.get('BUCKET_NAME') ?? 'epess', `documents/${id}`)
|
||||
const stream = this.minioClient.listObjects(this.configService.get('BUCKET_NAME') ?? 'epess', `documents/${id}/`)
|
||||
const items: BucketItem[] = []
|
||||
|
||||
stream.on('data', (item) => items.push(item))
|
||||
stream.on('end', () => resolve(items.length))
|
||||
stream.on('error', (err) => reject(err))
|
||||
stream.on('data', (item) => {
|
||||
items.push(item)
|
||||
})
|
||||
stream.on('end', () => {
|
||||
resolve(items.length)
|
||||
})
|
||||
stream.on('error', (err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
// export document to docx format by get all pages and convert to docx
|
||||
|
||||
Reference in New Issue
Block a user