Reputation: 664
In my application I am be able to upload some images to my blob storage on Windows Azure. And now im developing the second part of my application, retrieve the images from the Azure server, and show them in a picturebox.
I have tried several things:
listboxPictures.Items.Clear();
iTotalPictures = 0;
CloudBlobClient blobClient =
new CloudBlobClient("http://ferryjongmans.blob.core.windows.net/",
new StorageCredentialsSharedAccessSignature(signature));
CloudBlobContainer container = blobClient.GetContainerReference(comboBox1.SelectedItem.ToString());
CloudBlobDirectory direct = container.GetDirectoryReference(comboBox1.SelectedItem.ToString());
BlobRequestOptions options = new BlobRequestOptions();
options.UseFlatBlobListing = true;
options.BlobListingDetails = BlobListingDetails.Snapshots;
foreach (var blobItem in direct.ListBlobs(options))
{
listboxPictures.Items.Add(blobItem.Uri.ToString());
iTotalPictures ++;
lblTotal.Text = "Total frames: "+Convert.ToString(iTotalPictures);
pictureBox1.ImageLocation = blobItem.Uri.ToString(); // This is the display box, this works only with public settings on the container
}
This works, but only when the container is public (setting in Azure control panel). But I want to get my images when I have my container on private.
Who can help me please?
(I hope the description is clearly enough)
Application when my blobcontainer settings are on public Application when my blobcontainer settings are on private
Upvotes: 2
Views: 1626
Reputation: 136196
First, make sure that your SAS signature has "Read" permission defined ("List" permission will only allow listing blobs in a blob container). Then replace the following line of code:
pictureBox1.ImageLocation = blobItem.Uri.ToString();
With:
pictureBox1.ImageLocation = blobItem.Uri.ToString() + signature;
The reason you're not able to see pictures is because the URI you're getting for the blob does not have a SAS component attached to it.
Upvotes: 2