I have the listview code for downloading the blob container. But I need to only get a subfolder in the container, not the whole thing. Is there a way to add the variable for the subfolder or should I structure the data in Azure differently and create a new container instead of using subfolders in one container?
public static async Task<List<string>> GetUploadedImages(AzureStorageConfig _storageConfig)
{
List<ImageViewModel
> images = new List<ImageViewModel
>();
// Create BlobServiceClient from the account URI
BlobServiceClient blobServiceClient = new BlobServiceClient(_storageConfig.ConnectionString);
// Get reference to the container
BlobContainerClient container = blobServiceClient.GetBlobContainerClient(_storageConfig.ImageContainer);
if (container.Exists())
{
var data = container.GetBlobs();
foreach (BlobItem blobItem in container.GetBlobs())
{
images.Add(container.Uri + "/" + blobItem.Name);
}
}
return await Task.FromResult(images);
}
In the GetBlobsAsync method there should be a prefix parameter which you can use like a path for the folder you're targeting, have you tried this?
var Container = await GetCloudBlobClientAsync(); await foreach (BlobItem blob in Container.GetBlobsAsync(BlobTraits.None, BlobStates.None, path)) { //do something with your blob }