Skip to content

Commit

Permalink
Add constructure to have facility to upload to different containers O…
Browse files Browse the repository at this point in the history
…live.Blob.Azure
  • Loading branch information
atir-naveed-geeksltd committed Jan 7, 2025
1 parent 5de56bc commit 5cef73a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions Olive.Blob.Azure/AzureBlobStorageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,36 @@ namespace Olive.BlobAzure
{
public class AzureBlobStorageProvider : IBlobStorageProvider
{
BlobServiceClient BlobServiceClient => new BlobServiceClient(AzureBlobInfo.StorageConnectionString);
BlobServiceClient BlobServiceClient;
BlobContainerClient BlobContainerClient;

string ContainerName = AzureBlobInfo.StorageContainer;

public AzureBlobStorageProvider()
{
BlobServiceClient = new BlobServiceClient(AzureBlobInfo.StorageConnectionString);
}

public AzureBlobStorageProvider(BlobServiceClient blobServiceClient)
{
BlobServiceClient = blobServiceClient;
}

public AzureBlobStorageProvider(BlobServiceClient blobServiceClient, string containerName)
{
BlobServiceClient = blobServiceClient;
ContainerName = containerName;
}


static ILogger Log => Olive.Log.For(typeof(AzureBlobStorageProvider));

public bool CostsToCheckExistence() => true;

async Task<BlobContainerClient> GetBlobContainer()
{
if (BlobContainerClient == null)
return BlobContainerClient = BlobServiceClient.GetBlobContainerClient(AzureBlobInfo.StorageContainer);
return BlobContainerClient = BlobServiceClient.GetBlobContainerClient(ContainerName);

return BlobContainerClient;
}
Expand Down
2 changes: 1 addition & 1 deletion Olive.Blob.Azure/Olive.Blob.Azure.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>3.1.116</Version>
<Version>3.1.117</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 5cef73a

Please sign in to comment.