I am trying to achieve a similar experience as in your CardView demo with the cities. The images are stored as block blobs in an Azure storage account. The blobs have tags, which i want to expose , similar to the meta from the demo where we have city name, population, country).
As far as i saw, there is no direct integration for CloudBlockBlob, so i am trying to place this in a byte array in order to display. Yet the outcome is an empty box in the grid, for each item from the container. the blobs are correctly downloaded, verified by writing the fileContent byte array to disk via filestream.
Any idea on how to achieve this?
Thank you!
public partial class Form1 : Form
{
string sasToken = "?st=2020-02-12T21%3A05%3A08Z&se=2021-02-13T21%3A05%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=*redacted*";
public Form1()
{
InitializeComponent();
}
public List<IListBlobItem> MainBody3(string id)
{
StorageCredentials accountSAS = new StorageCredentials(sasToken);
// Use these credentials and the account name to create a Blob service client.
CloudStorageAccount account = new CloudStorageAccount(accountSAS, "storage_account_name", endpointSuffix: null, useHttps: true);
CloudBlobClient client = account.CreateCloudBlobClient();
CloudBlobContainer container = client.GetContainerReference("images-analyzed-sampled");
BlobContinuationToken token = null;
List<BlobInfo> blobi = new List<BlobInfo>();
List<IListBlobItem> poze = new List<IListBlobItem>();
BlobRequestOptions options = new BlobRequestOptions();
var myResults = new DataSet();
do
{
var result = container.ListBlobsSegmented(null, true, new BlobListingDetails(), 20, token, null, null);
token = result.ContinuationToken;
var blobs = result.Results;
foreach (IListBlobItem item in blobs)
{
var blob = item as CloudBlockBlob;
long fileByteLength = blob.Properties.Length;
byte[] fileContent = new byte[fileByteLength];
for (int i = 0; i < fileByteLength; i++)
{
fileContent[i] = 0x20;
}
radCardView1.Items.Add(blob.DownloadToByteArray(fileContent, 0));
}
} while (token != null);
return poze;
}
private bool HasMatchingMetadata(CloudBlockBlob blob, string term)
{
foreach (var item in blob.Metadata)
{
if (((item.Key.StartsWith("Tag") || (item.Key.StartsWith("PredictedImageType"))) && item.Value.Equals(term, StringComparison.InvariantCultureIgnoreCase)))
return true;
}
return false;
}
private void radButton1_Click(object sender, EventArgs e)
{
MainBody3("");
}
}
public class BlobInfo
{
public string ImageUri { get; set; }
public string ThumbnailUri { get; set; }
public string Caption { get; set; }
}
}