DEV Community

loizenai
loizenai

Posted on

Amazon S3 – Delete File SpringBoot RestAPI

https://grokonez.com/aws/amazon-s3/amazon-s3-delete-file-springboot-restapi

Amazon S3 – Delete File SpringBoot RestAPI

In the tutorial, we build a SpringBoot RestAPIs to Delete files in a Amazon S3 bucket.

Previous post:
Amazon S3 – SpringBoot RestAPIs Upload/Download File/Image to S3

Technologies

  • Java 8
  • Maven 3.6.1
  • Spring Tool Suite: 3.9.4.RELEASE
  • Spring Boot: 2.0.4.RELEASE
  • Amazon S3

AmazonS3 Delete File API

We use delete API in com.amazonaws.services.s3.AmazonS3.java ->


public void deleteObject(DeleteObjectRequest deleteObjectRequest)
    throws SdkClientException, AmazonServiceException;
  • @param deleteObjectRequest: The request object containing all options for deleting an Amazon S3 object.
  • @throws SdkClientException: If any errors are encountered in the client while making the request or handling the response.
  • @throws AmazonServiceException: If any errors occurred in Amazon S3 while processing the request.

Practice

We re-use all the sourcecode of the previous tutorial:

-> Amazon S3 – SpringBoot RestAPIs Upload/Download File/Image to S3

spring-boot-restapi-delete-files-amazon-s3 + project-structure

What we build more? ->

  • Implement deleteFile service
  • Expose deleteFile RestAPI

More at:

https://grokonez.com/aws/amazon-s3/amazon-s3-delete-file-springboot-restapi

Amazon S3 – Delete File SpringBoot RestAPI

Top comments (0)