import { BlobServiceClient } from "@azure/storage-blob";
import { config } from "../../config.js";
export async function uploadToAzure(buffer, originalName, mimeType) {
    const serviceClient = BlobServiceClient.fromConnectionString(config.azureStorageConnectionString);
    const containerClient = serviceClient.getContainerClient(config.azureBlobContainer);
    const blobName = `${Date.now()}-${originalName.replace(/[^a-zA-Z0-9._-]/g, "_")}`;
    const blockBlobClient = containerClient.getBlockBlobClient(blobName);
    await blockBlobClient.upload(buffer, buffer.length, {
        blobHTTPHeaders: { blobContentType: mimeType }
    });
    return blockBlobClient.url;
}
