此页面仅适用于使用 Vaults 和 2012 年原始 REST API 的 Amazon Glacier 服务的现有客户。
如果您正在寻找档案存储解决方案,我们建议您在亚马逊 S3、S3 Glacier 即时检索、S3 Glacier 灵活检索和 S3 Glacier Deep Archive Deep Archive 中使用 Amazon Glacier 存储类。要了解有关这些存储选项的更多信息,请参阅 Amazon Glacier 存储类别
从 2025 年 12 月 15 日起,Amazon Glacier(最初基于保管库的独立服务)将不再接受新客户,对现有客户不产生任何影响。Amazon Glacier 是一项独立的服务 APIs ,拥有自己的服务,可将数据存储在文件库中,不同于亚马逊 S3 和 Amazon S3 Glacier 存储类别。在 Amazon Glacier 中,您的现有数据将保持安全且可以无限期地访问。无需迁移。对于低成本、长期的存档存储, Amazon 建议使用 Amazon S3 Glacier 存储类别,这些存储类别
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用 Amazon Glacier 中的文件库下载档案 适用于 .NET 的 Amazon SDK
以下 C# 代码示例使用的高级别 API 下载您之前在中上传的档案使用 Amazon Glacier 将档案上传到文件库 适用于 .NET 的 Amazon SDK。 适用于 .NET 的 Amazon SDK 在代码示例中,请注意以下情况:
-
该示例为指定的 Amazon Glacier 区域终端节点创建该
ArchiveTransferManager类的实例。 -
该代码示例使用美国西部(俄勒冈州)区域 (
us-west-2) 匹配您之前在第 2 步:在 Amazon Glacier 中创建文件库中创建文件库的位置。 -
该示例使用
Download类的ArchiveTransferManagerAPI 操作下载档案。该示例将创建 Amazon Simple Notification Service (Amazon SNS) 主题,以及该主题订阅的 Amazon Simple Queue Service (Amazon SQS) 队列。如果您按照中的说明创建了 Amazon Identity and Access Management (IAM) 管理员用户第 1 步:开始使用 Amazon Glacier 之前,则您的用户拥有创建和使用 Amazon SNS 主题和 Amazon SQS 队列所必需的 IAM 权限。 -
此示例启动了存档检索任务,并对队列进行轮询以便找到可用存档。如果档案可用,则开始下载。有关检索时间的详细信息,请参阅 档案检索选项。
有关如何运行此示例的 step-by-step说明,请参阅运行代码示例。您需要更新 步骤 3:将档案上传到 Amazon Glacier 中的文件库 中已上传文件的档案 ID 旁显示的代码。
例 — 使用的高级别 API 下载档案 适用于 .NET 的 Amazon SDK
using System; using Amazon.Glacier; using Amazon.Glacier.Transfer; using Amazon.Runtime; namespace glacier.amazon.com.docsamples { class ArchiveDownloadHighLevel_GettingStarted { static string vaultName = "examplevault"; static string archiveId = "*** Provide archive ID ***"; static string downloadFilePath = "*** Provide the file name and path to where to store the download ***"; public static void Main(string[] args) { try { var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USWest2); var options = new DownloadOptions(); options.StreamTransferProgress += ArchiveDownloadHighLevel_GettingStarted.progress; // Download an archive. Console.WriteLine("Intiating the archive retrieval job and then polling SQS queue for the archive to be available."); Console.WriteLine("Once the archive is available, downloading will begin."); manager.Download(vaultName, archiveId, downloadFilePath, options); Console.WriteLine("To continue, press Enter"); Console.ReadKey(); } catch (AmazonGlacierException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("To continue, press Enter"); Console.ReadKey(); } static int currentPercentage = -1; static void progress(object sender, StreamTransferProgressArgs args) { if (args.PercentDone != currentPercentage) { currentPercentage = args.PercentDone; Console.WriteLine("Downloaded {0}%", args.PercentDone); } } } }