在 Snowball Edge 上刪除 Amazon S3 相容儲存貯體中的物件 - AWS Snowball 邊緣 開發人員指南

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

在 Snowball Edge 上刪除 Amazon S3 相容儲存貯體中的物件

您可以從 Snowball Edge 儲存貯體上的 Amazon S3 相容儲存體中刪除一或多個物件。下列範例會使用 刪除名為 sample-object.xml 的物件 AWS CLI。若要使用此命令,請以您自己的資訊取代每個 使用者輸入預留位置。

aws s3api delete-object --bucket sample-bucket --key key --endpoint-url s3api-endpoint-ip --profile your-profile

如需此命令的詳細資訊,請參閱 AWS CLI 命令參考中的 delete-object

下列 Snowball Edge 上的 Amazon S3 相容儲存體範例會使用適用於 Java 的 SDK 刪除儲存貯體中的物件。若要使用此範例,請指定您要刪除之物件的金鑰名稱。如需詳細資訊,請參閱《Amazon Simple Storage Service API 參考》中的 DeleteObject

import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.model.DeleteObjectRequest; public class DeleteObject { public static void main(String[] args) { String bucketName = "*** Bucket name ***"; String keyName = "*** key name ****"; try { // This code expects that you have AWS credentials set up per: // https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-credentials.html AmazonS3 s3Client = AmazonS3ClientBuilder.standard() .enableUseArnRegion() .build(); DeleteObjectRequest deleteObjectRequest = DeleteObjectRequest.builder() .bucket(bucketName) .key(keyName) .build())); s3Client.deleteObject(deleteObjectRequest); } catch (AmazonServiceException e) { // The call was transmitted successfully, but Amazon S3 couldn't process // it, so it returned an error response. e.printStackTrace(); } catch (SdkClientException e) { // Amazon S3 couldn't be contacted for a response, or the client // couldn't parse the response from Amazon S3. e.printStackTrace(); } } }