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


  • 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 ->

  • @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.


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
Implement S3 Delete Files service

– Add deleteFile function in interface:

– Implement deleteFiles in

Expose Delete Files RestAPI

Create DeleteFileController controller ->

Run & Check results

Build & Run the SpringBoot sourcecode with commandlines {mvn clean install, mvn spring-boot:run}.

– File on Amazon S3 ->

spring-boot-restapi-delete-files-amazon-s3 + upload-file-on-s3

– Delete File:

spring-boot-restapi-delete-files-amazon-s3 + delete-file-on-s3


– In file, change & to yours.

– Sourcecode -> SpringS3Amazon

By grokonez | August 8, 2018.

Related Posts

Got Something To Say:

Your email address will not be published. Required fields are marked *