使用Amazon开发工具包删除Amazon S3 Glacier 档案 - Simple Storage Service(Amazon S3)Glacier
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

使用Amazon开发工具包删除Amazon S3 Glacier 档案

以下代码示例显示如何删除 Amazon S3 Glacier 文件库。

Java
SDK for Java 2.x
注意

还有更多 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

public static void deleteGlacierArchive(GlacierClient glacier, String vaultName, String accountId, String archiveId) { try { DeleteArchiveRequest delArcRequest = DeleteArchiveRequest.builder() .vaultName(vaultName) .accountId(accountId) .archiveId(archiveId) .build(); glacier.deleteArchive(delArcRequest); System.out.println("The vault was deleted!"); } catch(GlacierException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
Python
适用于 Python (Boto3) 的 SDK
注意

还有更多 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

class GlacierWrapper: """Encapsulates Amazon S3 Glacier API operations.""" def __init__(self, glacier_resource): """ :param glacier_resource: A Boto3 Amazon S3 Glacier resource. """ self.glacier_resource = glacier_resource @staticmethod def delete_archive(archive): """ Deletes an archive from a vault. :param archive: The archive to delete. """ try: archive.delete() logger.info( "Deleted archive %s from vault %s.", archive.id, archive.vault_name) except ClientError: logger.exception("Couldn't delete archive %s.", archive.id) raise
  • 有关 API 详细信息,请参阅DeleteArchiveAmazonSDK for Python (Boto3) API 参考》中的说明。

有关 Amazon 软件开发工具包开发人员指南和代码示例的完整列表,请参阅 将 S3 Glacier 与结合使用Amazon开发工具包。本主题还包括有关入门的信息以及有关先前的软件开发工具包版本的详细信息。