using Azure.Storage.Blobs; using Azure.Storage.Blobs.Models; using Azure.Storage.Blobs.Specialized; using DamageAssesment.Api.DocuLinks.Interfaces; namespace DamageAssesment.Api.DocuLinks.Providers { public class AzureBlobService: IAzureBlobService { BlobServiceClient _blobClient; BlobContainerClient _containerClient; string azureConnectionString = ""; public AzureBlobService() { _blobClient = new BlobServiceClient(azureConnectionString); _containerClient = _blobClient.GetBlobContainerClient("apiimages"); } public async Task>> UploadFiles(List files) { var azureResponse = new List>(); foreach (var file in files) { string fileName = file.FileName; using (var memoryStream = new MemoryStream()) { file.CopyTo(memoryStream); memoryStream.Position = 0; var client = await _containerClient.UploadBlobAsync(fileName, memoryStream, default); azureResponse.Add(client); } }; return azureResponse; } public void DeleteFile(string url) { var blob = _containerClient.GetBlockBlobClient(url); blob.DeleteIfExists(); } } }