Can't delete directory from Amazon S3

前端 未结 10 2119
醉梦人生
醉梦人生 2021-02-12 07:19

I\'m using the web interface of Amazon\'s S3, and when I right-click a folder X and choose Delete, X seems to be deleted. Then when I refresh the interface, X may either disappe

10条回答
  •  失恋的感觉
    2021-02-12 08:12

    I had the same problem and didn't have access to the amazon console but I could delete it with this Java code

        AmazonS3Client amazonS3Client = new AmazonS3Client(basicAWSCredentials);
        ObjectListing objectListing = amazonS3Client.listObjects("bucketName", "prefix");
        DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest("bucketName");
        List keysToDelete = new ArrayList<>();
        objectListing.getObjectSummaries().forEach(s3ObjectSummary -> {
            keysToDelete.add(new DeleteObjectsRequest.KeyVersion(s3ObjectSummary.getKey()));
        });
        deleteObjectsRequest.setKeys(keysToDelete);
        amazonS3Client.deleteObjects(deleteObjectsRequest);
    

        
            com.amazonaws
            aws-java-sdk
            1.7.4
        
    

提交回复
热议问题