As mentioned in the Windows Azure Storage BLOB Overview, Windows Azure Storage Blobs does not have the concept of a subfolder, which is part of the file name. For example
Http://myaccount.blob.core.windows.net/pictures/trips/seattle/spaceneedle.jpg
At first glance you might think that there are multiple tree-level folders "Pictures", "trips" and "Seattle" that correspond to the namespace of this blob, but in fact many of the members in all the paths are only the names of the binary files themselves. In this example, the name of the container (container) is "pictures" and the stored binary file name is "Trips/seattle/spaceneedle.jpg".
Attach a Console Mode Creator sample program code to upload a picture img_2956.jpg on a local hard drive to Windows Azure Storage a container named Image (Container), and this BLOB File name is Subfolder1\subfolder1a\img_2956.jpg
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Add some namespace
Using System.Configuration;
Using Microsoft.WindowsAzure.Storage;
Using Microsoft.WindowsAzure.Storage.Auth;
Using Microsoft.WindowsAzure.Storage.Blob;
Namespace Blobsample
{
Class Program
{
static void Main (string] args)
{
Retrieve Storage account from connection string.
Cloudstorageaccount Storageaccount = Cloudstorageaccount.parse ("DEFAULTENDPOINTSPROTOCOL=HTTPS; Accountname=[your account name]; Accountkey=[your Key] ");
Create the BLOB client.
Cloudblobclient blobclient = Storageaccount.createcloudblobclient ();
Retrieve reference to a previously created container.
Cloudblobcontainer container = blobclient.getcontainerreference ("image");
Retrieve reference to a blob named "Subfolder1\\subfolder1a\\img_2956.jpg".
Cloudblockblob Blockblob = container. Getblockblobreference ("subfolder1\\subfolder1a\\img_2956.jpg");
Create or overwrite the "subfolder1\\subfolder1a\\img_2956.jpg" blob with contents to a local file img_2956.jpg.
using (var FileStream = System.IO.File.OpenRead (@ "img_2956.jpg"))
{
Blockblob.uploadfromstream (FileStream);
}
System.Console.WriteLine ("complete!");
System.Console.ReadKey ();
}
}
}
If you use tools such as Cloudxplorer, to make Azure Storage Blobs analog as a file explorer, let the user look like there are two levels of subfolders Subfolder1 and Subfolder1a, but remember that this is actually a container for image ( Container), a binary file named subfolder1\subfolder1a\img_2956.jpg is stored.