feat: add record URL retrieval to MeetingRoom schema and enhance MinioService

- Introduced a new field `recordUrl` in the MeetingRoom schema to fetch the presigned URL for meeting room recordings.
- Implemented `getRoomRecordUrl` method in MinioService to retrieve the recording URL from Minio, enhancing the service's functionality.
- Updated imports in MeetingRoom schema to include MinioService for the new functionality.
This commit is contained in:
2024-12-05 21:10:45 +07:00
parent 62662b0256
commit 10df93d534
2 changed files with 27 additions and 5 deletions

View File

@@ -123,10 +123,6 @@ export class MinioService {
})
})
}
listRecords(roomId: string) {
return this.minioClient.listObjects(this.configService.get('BUCKET_NAME') ?? 'epess', `epess/records/${roomId}`)
}
// export document to docx format by get all pages and convert to docx
async exportDocument(id: string) {
// get all pages
@@ -141,4 +137,22 @@ export class MinioService {
// generate a unique file name using uuid
return uuidv4()
}
// get the record url from minio by searching for the file starting with roomId and ending with .mp4 and returning the presigned url
async getRoomRecordUrl(roomId: string) {
return new Promise<string | null>(async (resolve, reject) => {
const stream = this.minioClient.listObjects(this.configService.get('BUCKET_NAME') ?? 'epess', `records/${roomId}`, true)
const items: BucketItem[] = []
stream.on('data', (item) => {
items.push(item)
})
stream.on('end', async () => {
const record = items.find((item) => item.name?.endsWith('.mp4'))
resolve(record ? await this.minioClient.presignedUrl('GET', this.configService.get('BUCKET_NAME') ?? 'epess', record.name ?? '') : null)
})
stream.on('error', (err) => {
reject(err)
})
})
}
}