openvidu-call: Avoided create a base64 image for recording thumbnail
This commit is contained in:
parent
cf6e2545e5
commit
5c6e052efa
@ -4,7 +4,6 @@
|
||||
"url": "https://github.com/OpenVidu/openvidu-call/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "0.27.2",
|
||||
"btoa": "1.2.1",
|
||||
"cookie-parser": "1.4.6",
|
||||
"cookie-session": "^2.0.0",
|
||||
|
||||
@ -24,7 +24,7 @@ app.post('/login', async (req: Request, res: Response) => {
|
||||
req['session'] = { token };
|
||||
openviduService.adminTokens.push(token);
|
||||
}
|
||||
const recordings = await openviduService.listAllRecordings(true);
|
||||
const recordings = await openviduService.listAllRecordings();
|
||||
console.log(`${recordings.length} recordings found`);
|
||||
res.status(200).send(JSON.stringify({ recordings }));
|
||||
} catch (error) {
|
||||
|
||||
@ -19,7 +19,7 @@ app.get('/', async (req: Request, res: Response) => {
|
||||
let recordings = [];
|
||||
if ((!!sessionId && IS_RECORDING_ENABLED && openviduService.isValidToken(sessionId, req.cookies)) || isAdminDashboard) {
|
||||
if (isAdminDashboard) {
|
||||
recordings = await openviduService.listAllRecordings(true);
|
||||
recordings = await openviduService.listAllRecordings();
|
||||
} else {
|
||||
const date = openviduService.getDateFromCookie(req.cookies);
|
||||
recordings = await openviduService.listRecordingsBySessionIdAndDate(sessionId, date);
|
||||
@ -113,7 +113,7 @@ app.delete('/delete/:recordingId', async (req: Request, res: Response) => {
|
||||
console.log(`Deleting recording ${recordingId}`);
|
||||
await openviduService.deleteRecording(recordingId);
|
||||
if (isAdminDashboard && !!req['session']) {
|
||||
recordings = await openviduService.listAllRecordings(true);
|
||||
recordings = await openviduService.listAllRecordings();
|
||||
} else {
|
||||
const date = openviduService.getDateFromCookie(req.cookies);
|
||||
recordings = await openviduService.listRecordingsBySessionIdAndDate(sessionId, date);
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { Connection, ConnectionProperties, OpenVidu, OpenViduRole, Recording, Session, SessionProperties } from 'openvidu-node-client';
|
||||
import { OPENVIDU_URL, OPENVIDU_SECRET } from '../config';
|
||||
import axios from 'axios';
|
||||
|
||||
export class OpenViduService {
|
||||
RECORDING_TOKEN_NAME = 'ovCallRecordingToken';
|
||||
@ -101,17 +100,8 @@ export class OpenViduService {
|
||||
return this.openvidu.getRecording(recordingId);
|
||||
}
|
||||
|
||||
public async listAllRecordings(withB64Thumbnail: boolean = false): Promise<Recording[]> {
|
||||
let recordings = await this.openvidu.listRecordings();
|
||||
if (withB64Thumbnail) {
|
||||
for (const rec of recordings) {
|
||||
let thumbnailUrl = `${rec.url.substring(0, rec.url.lastIndexOf('/'))}/${rec.id}.jpg`;
|
||||
const headers = { Authorization: this.getBasicAuth() };
|
||||
let image = await axios.get(thumbnailUrl, { headers, responseType: 'arraybuffer' });
|
||||
rec['thumbnailB64'] = `data:${image.headers['content-type']};base64,${Buffer.from(image.data).toString('base64')}`;
|
||||
}
|
||||
}
|
||||
return recordings;
|
||||
public async listAllRecordings(): Promise<Recording[]> {
|
||||
return await this.openvidu.listRecordings();
|
||||
}
|
||||
|
||||
public async listRecordingsBySessionIdAndDate(sessionId: string, date: number) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user