Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
此页面仅适用于使用文件库和 2012 年原始 REST API 的 S3 Glacier 服务的现有客户。
如果您正在寻找归档存储解决方案,建议使用 Amazon S3 中的 S3 Glacier 存储类 S3 Glacier Instant Retrieval、S3 Glacier Flexible Retrieval 和 S3 Glacier Deep Archive。要了解有关这些存储选项的更多信息,请参阅《Amazon S3 用户指南》中的 S3 Glacier 存储类和使用 S3 Glacier 存储类的长期数据存储。这些存储类使用 Amazon S3 API,适用于所有区域,并且可以在 Amazon S3 控制台中管理。它们提供存储成本分析、Storage Lens 存储分析功能、高级可选加密功能等功能。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
以下代码示例演示如何使用 ListTagsForVault
。
- .NET
-
- 适用于 .NET 的 Amazon SDK
-
/// <summary>
/// List tags for an Amazon S3 Glacier vault.
/// </summary>
/// <param name="vaultName">The name of the vault to list tags for.</param>
/// <returns>A dictionary listing the tags attached to each object in the
/// vault and its tags.</returns>
public async Task<Dictionary<string, string>> ListTagsForVaultAsync(string vaultName)
{
var request = new ListTagsForVaultRequest
{
// Using a hyphen "-" for the Account Id will
// cause the SDK to use the Account Id associated
// with the default user.
AccountId = "-",
VaultName = vaultName,
};
var response = await _glacierService.ListTagsForVaultAsync(request);
return response.Tags;
}
- CLI
-
- Amazon CLI
-
以下命令列出应用于名为 my-vault
的文件库的标签:
aws glacier list-
tags-for-vault --account-id - --vault-name my-vault
输出:
{
"Tags": {
"date": "july2015",
"id": "1234"
}
}
Amazon Glacier 在执行操作时需要一个账户 ID 参数,但您可以使用连字符来指定正在使用的账户。
有关 S Amazon DK 开发者指南和代码示例的完整列表,请参阅将 S3 Glacier 与 S Amazon DK 配。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。