使用Amazon SDK for .NET 从 S3 Glacier 的文件库中删除档案 - Amazon S3 Glacier
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

如果您不熟悉 Amazon Simple Storage Service (Amazon S3) 中的归档存储功能,建议您先详细了解 Amazon S3 中的 S3 Glacier 存储类、S3 Glacier 即时检索S3 Glacier 灵活检索S3 Glacier 深度归档。有关更多信息,请参阅 Amazon S3 用户指南中的 S3 Glacier 存储类和用于存档对象的存储类。

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用Amazon SDK for .NET 从 S3 Glacier 的文件库中删除档案

以下 C# 代码示例使用Amazon SDK for .NET 高级 API 来删除您在之前的步骤中上传的档案。在代码示例中,请注意以下情况:

  • 该示例为指定的 Amazon S3 Glacier 区域端点创建 ArchiveTransferManager 类的实例。

  • 该代码示例使用美国西部(俄勒冈州)区域 (us-west-2)。

  • 该示例使用 ArchiveTransferManager 类的 Delete API 操作,该类属于Amazon SDK for .NET的高级 API。

有关如何运行以下示例的分步说明,请参阅运行代码示例。您需要更新 步骤 3:在 S3 Glacier 中将存档上传到文件库 中已上传文件的档案 ID 旁显示的代码。

例 — 使用Amazon SDK for .NET 高级 API 删除档案
using System; using Amazon.Glacier; using Amazon.Glacier.Transfer; using Amazon.Runtime; namespace glacier.amazon.com.docsamples { class ArchiveDeleteHighLevel_GettingStarted { static string vaultName = "examplevault"; static string archiveId = "*** Provide archive ID ***"; public static void Main(string[] args) { try { var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USWest2); manager.DeleteArchive(vaultName, archiveId); } 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(); } } }