advanced-features: azure-advanced-recording-tutorial - changed all s3 references

This commit is contained in:
Piwccle 2025-06-03 17:04:21 +02:00
parent b1aeb2f2f2
commit 75076678a5
3 changed files with 11 additions and 18 deletions

View File

@ -7,7 +7,7 @@ LIVEKIT_API_SECRET=secret
# Recording configuration
RECORDINGS_PATH=recordings/
RECORDING_PLAYBACK_STRATEGY=S3
RECORDING_PLAYBACK_STRATEGY=AZURE
# Azure Blob Storage configuration
AZURE_ACCOUNT_NAME=yourstorageaccountname

View File

@ -6,13 +6,6 @@ export const LIVEKIT_URL = process.env.LIVEKIT_URL || "http://localhost:7880";
export const LIVEKIT_API_KEY = process.env.LIVEKIT_API_KEY || "devkey";
export const LIVEKIT_API_SECRET = process.env.LIVEKIT_API_SECRET || "secret";
// S3 configuration
export const S3_ENDPOINT = process.env.S3_ENDPOINT || "http://localhost:9000";
export const S3_ACCESS_KEY = process.env.S3_ACCESS_KEY || "minioadmin";
export const S3_SECRET_KEY = process.env.S3_SECRET_KEY || "minioadmin";
export const AWS_REGION = process.env.AWS_REGION || "us-east-1";
export const S3_BUCKET = process.env.S3_BUCKET || "openvidu";
// Azure Blob Storage configuration
export const AZURE_ACCOUNT_NAME = process.env.AZURE_ACCOUNT_NAME || "your_account_name";
export const AZURE_ACCOUNT_KEY = process.env.AZURE_ACCOUNT_KEY || "your_account_key";
@ -21,5 +14,5 @@ export const AZURE_ENDPOINT = process.env.AZURE_ENDPOINT || `https://${AZURE_ACC
export const RECORDINGS_PATH = process.env.RECORDINGS_PATH ?? "recordings/";
export const RECORDINGS_METADATA_PATH = ".metadata/";
export const RECORDING_PLAYBACK_STRATEGY = process.env.RECORDING_PLAYBACK_STRATEGY || "S3"; // PROXY or S3
export const RECORDING_PLAYBACK_STRATEGY = process.env.RECORDING_PLAYBACK_STRATEGY || "AZURE"; // PROXY or S3
export const RECORDING_FILE_PORTION_SIZE = 5 * 1024 * 1024; // 5MB

View File

@ -44,32 +44,32 @@ export class AzureBlobService {
return AzureBlobService.instance;
}
// Sube un objeto (JSON) al contenedor
// Uploads an object (JSON) to the container
async uploadObject(key, body) {
const blockBlobClient = this.containerClient.getBlockBlobClient(key);
const data = JSON.stringify(body);
await blockBlobClient.upload(data, Buffer.byteLength(data));
}
// Comprueba si existe un blob
// Checks if a blob exists
async exists(key) {
const blobClient = this.containerClient.getBlobClient(key);
return await blobClient.exists();
}
// Obtiene las propiedades del blob (equivalente a headObject)
// Gets the blob properties (equivalent to headObject)
async headObject(key) {
const blobClient = this.containerClient.getBlobClient(key);
return await blobClient.getProperties();
}
// Devuelve el tamaño del blob en bytes
// Returns the blob size in bytes
async getObjectSize(key) {
const props = await this.headObject(key);
return props.contentLength || 0;
}
// Descarga el blob completo o un rango, devolviendo el stream
// Downloads the complete blob or a range, returning the stream
async getObject(key, range) {
const blobClient = this.containerClient.getBlobClient(key);
let downloadResponse;
@ -86,7 +86,7 @@ export class AzureBlobService {
return downloadResponse.readableStreamBody;
}
// Genera un URL SAS válido 24 horas
// Generates a valid SAS URL for 24 hours
async getObjectUrl(key) {
if (!AZURE_ACCOUNT_NAME || !AZURE_ACCOUNT_KEY) {
throw new Error("Credenciales de cuenta de Azure no están definidas para generar SAS");
@ -108,7 +108,7 @@ export class AzureBlobService {
return `${blobClient.url}?${sasToken}`;
}
// Obtiene el contenido JSON del blob
// Gets the JSON content of the blob
async getObjectAsJson(key) {
const exists = await this.exists(key);
if (!exists) {
@ -128,7 +128,7 @@ export class AzureBlobService {
});
}
// Lista blobs bajo un prefijo y filtra por expresión regular
// Lists blobs under a prefix and filters by regular expression
async listObjects(prefix, regex) {
const results = [];
for await (const blob of this.containerClient.listBlobsFlat({ prefix })) {
@ -139,7 +139,7 @@ export class AzureBlobService {
return results;
}
// Elimina un blob
// Deletes a blob
async deleteObject(key) {
const blobClient = this.containerClient.getBlobClient(key);
await blobClient.delete();