我正在尝试将文件上传到 Windows Azure blob 存储。据我了解,您可以将文件上传到类似于子目录的内容中。我想将文件上传到 blob,以便该文件基本上驻留在/TestContainer/subDirectory1/subDirectory2/file.png
// Setup the Windows Aure blob client
CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting("BlobStorage");
CloudBlobClient client = storageAccount.CreateCloudBlobClient();
// Retrieve the TestContainer container from blob storage
CloudBlobContainer container = client.GetContainerReference("TestContainer");
if (container.CreateIfNotExist())
container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });
// Setup the blob
CloudBlob blob = container.GetBlobReference("");
// Create the meta data for the blob
NameValueCollection metadata = new NameValueCollection();
metadata["id"] = fileID.ToString();
blob.Metadata.Add(metadata);
// Store the blob
byte[] bytes = GetFileBytes();
blob.UploadByteArray(bytes);
如何上传具有目录结构的文件?这里的链接提到有一种方法可以做到这一点。但是,它并没有告诉你如何去做。
谢谢!