advanced-features: recording-basic-azure - updated service name and deleted some lines of .env refered to s3

This commit is contained in:
Piwccle 2025-06-03 11:06:54 +02:00
parent 8841cd2aed
commit d5dd493a37
3 changed files with 1 additions and 100 deletions

View File

@ -5,14 +5,6 @@ LIVEKIT_URL=http://localhost:7880
LIVEKIT_API_KEY=devkey
LIVEKIT_API_SECRET=secret
# S3 configuration
S3_ENDPOINT=http://localhost:9000
S3_ACCESS_KEY=minioadmin
S3_SECRET_KEY=minioadmin
AWS_REGION=us-east-1
S3_BUCKET=openvidu
RECORDINGS_PATH=recordings/
# Azure Blob Storage configuration
AZURE_ACCOUNT_NAME=yourstorageaccountname
AZURE_ACCOUNT_KEY=youraccountkey

View File

@ -1,91 +0,0 @@
import {
BlobServiceClient,
StorageSharedKeyCredential,
} from "@azure/storage-blob";
// Azure configuration
const AZURE_ACCOUNT_NAME = process.env.AZURE_ACCOUNT_NAME || "devstoreaccount";
const AZURE_ACCOUNT_KEY =
process.env.AZURE_ACCOUNT_KEY || "nokey";
const AZURE_CONTAINER_NAME =
process.env.AZURE_CONTAINER_NAME || "openvidu-appdata";
const AZURE_ENDPOINT =
process.env.AZURE_ENDPOINT ||
`https://${AZURE_ACCOUNT_NAME}.blob.core.windows.net`;
export class AzureBlobService {
static instance;
constructor() {
if (AzureBlobService.instance) {
return AzureBlobService.instance;
}
const sharedKeyCredential = new StorageSharedKeyCredential(
AZURE_ACCOUNT_NAME,
AZURE_ACCOUNT_KEY
);
this.blobServiceClient = new BlobServiceClient(
AZURE_ENDPOINT,
sharedKeyCredential
);
this.containerClient = this.blobServiceClient.getContainerClient(
AZURE_CONTAINER_NAME
);
AzureBlobService.instance = this;
return this;
}
async exists(key) {
const blobClient = this.containerClient.getBlobClient(key);
return await blobClient.exists();
}
async getObjectSize(key) {
const props = await this.headObject(key);
return props.contentLength;
}
async headObject(key) {
const blobClient = this.containerClient.getBlobClient(key);
const props = await blobClient.getProperties();
return props;
}
async getObject(key, range) {
const blobClient = this.containerClient.getBlobClient(key);
const downloadOptions = range
? {
rangeGetContentMD5: false,
range: {
offset: range.start,
count: range.end - range.start + 1,
},
}
: {};
const response = await blobClient.download(
downloadOptions.range?.offset ?? 0,
downloadOptions.range?.count
);
return response.readableStreamBody;
}
async listObjects() {
const result = [];
for await (const blob of this.containerClient.listBlobsFlat()) {
result.push(blob);
}
return result;
}
async deleteObject(key) {
const blobClient = this.containerClient.getBlobClient(key);
return await blobClient.deleteIfExists();
}
}

View File

@ -10,7 +10,7 @@ import {
EncodedFileType,
WebhookReceiver,
} from "livekit-server-sdk";
import { AzureBlobService } from "./azure.blobstorage.js";
import { AzureBlobService } from "./azure.blobstorage.service.js";
// Configuration
const SERVER_PORT = process.env.SERVER_PORT || 6080;