

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# Snowball Edge の Amazon S3 互換ストレージ内のバケット内のオブジェクトの削除
<a name="objects-delete-s3-snow"></a>

Snowball Edge バケットの Amazon S3 互換ストレージから 1 つ以上のオブジェクトを削除できます。以下の例では、 AWS CLIを使用して {{sample-object.xml}} という名前のオブジェクトを削除します。このコマンドを使用するには、各ユーザー入力プレースホルダーを独自の情報に置き換えます。

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

このコマンドの詳細については、「**AWS CLI コマンドリファレンス」の「[delete-object](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3control/delete-object.html)」を参照してください。

次の Snowball Edge 上の Amazon S3 互換ストレージの例では、SDK for Java を使用してバケット内のオブジェクトを削除します。この例を使用するには、削除するオブジェクトのキー名を指定します。詳細については、「Amazon Simple Storage Service API リファレンス」の「[DeleteObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html)」を参照してください。

```
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();
        }
    }
}
```