[英]Setting and Retrieving metadata of blob in Azure Blob Storage
I was just wondering if its possible to set and retrieve metadata about a blob stored in a directory inside that container? 我只是想知道是否有可能设置和检索有关存储在该容器内目录中的Blob的元数据?
Yes, you can certainly do so. 是的,您当然可以这样做。 Please see the sample code below: 请参见下面的示例代码:
const string ConnectionString = "DefaultEndpointsProtocol=https;AccountName=account-name;AccountKey=account-key";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConnectionString);
//Create the service client object for credentialed access to the Blob service.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container.
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
CloudBlockBlob blob = container.GetBlockBlobReference("images/logo.png");
blob.FetchAttributes();//Gets the properties & metadata for the blob.
blob.Metadata.Add("Key", "Value");
blob.SetMetadata();//Saves the metadata.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.