title: Not able to Delete Objects from Amazon S3 using java?
body: <p>I am trying to list Objects based on prefix folder and delete each object.</p>
  
  <pre><code>AWSCredentials awsCredentials = new BasicAWSCredentials("accesskey", "secretkey");
  AmazonS3 s3client = new AmazonS3Client(awsCredentials);
  ListObjectsRequest listObjectsRequest = 
                 new ListObjectsRequest("bucketname","folder",null,"/",1000);
  
  s3client
        .listObjects(listObjectsRequest)
        .getObjectSummaries()
        .forEach(
            (file) -&gt; {
              DeleteObjectRequest deleteRequest = new DeleteObjectRequest("bucketname", file.getKey());
              s3client.deleteObject(deleteRequest);
            });
  </code></pre>
  
  <p>But i am getting following Exception</p>
  
  <p><strong>com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied;</strong> </p>
  
  <pre><code>    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
      at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4187)
      at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4134)
      at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:4128)
      at com.amazonaws.services.s3.AmazonS3Client.listObjects(AmazonS3Client.java:839)
  </code></pre>
  
  <p>The keys I am using are valid. I can perform other operations like <code>getobject()</code>.</p>
  
  <p>What am I doing wrong?</p>