繁体   English   中英

在Azure Blob存储中设置和检索Blob的元数据

[英]Setting and Retrieving metadata of blob in Azure Blob Storage

链接提到有关在容器级别存储和检索元数据的信息。 我只是想知道是否有可能设置和检索有关存储在该容器内目录中的Blob的元数据?

我只是想知道是否有可能设置和检索有关存储在该容器内目录中的Blob的元数据?

是的,您当然可以这样做。 请参见下面的示例代码:

        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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM