DeleteContainer 搭配 AWS SDK或 使用 CLI - AWS Elemental MediaStore

支援結束通知:2025 年 11 月 13 日, AWS 將停止對 AWS Elemental 的支援 MediaStore。2025 年 11 月 13 日之後,您將無法再存取 MediaStore 主控台或 MediaStore 資源。如需詳細資訊,請造訪此部落格文章

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

DeleteContainer 搭配 AWS SDK或 使用 CLI

下列程式碼範例示範如何使用 DeleteContainer

CLI
AWS CLI

刪除容器

下列delete-container範例會刪除指定的容器。只有當容器沒有任何物件時,您才可以將該容器刪除。

aws mediastore delete-container \ --container-name=ExampleLiveDemo

此命令不會產生輸出。

如需詳細資訊,請參閱 AWS 元素 MediaStore 使用者指南中的刪除容器

  • 如需API詳細資訊,請參閱 AWS CLI 命令參考DeleteContainer中的 。

Java
SDK 適用於 Java 2.x
注意

還有更多功能 GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

import software.amazon.awssdk.services.mediastore.MediaStoreClient; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.mediastore.model.CreateContainerRequest; import software.amazon.awssdk.services.mediastore.model.CreateContainerResponse; import software.amazon.awssdk.services.mediastore.model.MediaStoreException; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class CreateContainer { public static long sleepTime = 10; public static void main(String[] args) { final String usage = """ Usage: <containerName> Where: containerName - The name of the container to create. """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String containerName = args[0]; Region region = Region.US_EAST_1; MediaStoreClient mediaStoreClient = MediaStoreClient.builder() .region(region) .build(); createMediaContainer(mediaStoreClient, containerName); mediaStoreClient.close(); } public static void createMediaContainer(MediaStoreClient mediaStoreClient, String containerName) { try { CreateContainerRequest containerRequest = CreateContainerRequest.builder() .containerName(containerName) .build(); CreateContainerResponse containerResponse = mediaStoreClient.createContainer(containerRequest); String status = containerResponse.container().status().toString(); while (!status.equalsIgnoreCase("Active")) { status = DescribeContainer.checkContainer(mediaStoreClient, containerName); System.out.println("Status - " + status); Thread.sleep(sleepTime * 1000); } System.out.println("The container ARN value is " + containerResponse.container().arn()); System.out.println("Finished "); } catch (MediaStoreException | InterruptedException e) { System.err.println(e.getMessage()); System.exit(1); } } }
  • 如需API詳細資訊,請參閱 AWS SDK for Java 2.x API 參考DeleteContainer中的 。

如需開發人員指南和程式碼範例的完整清單 AWS SDK,請參閱 將此服務與 搭配使用 AWS SDK。本主題也包含入門的相關資訊,以及先前SDK版本的詳細資訊。