Spring's Resource API does not support the full lifecycle of operations. The two main interfaces are Resource
and WritableResource
. There is no API for deletion.
As an alternative you could use Spring Content for S3 instead. Spring Content Stores are all generic ResourceLoader
s that return Resource
s that DO support deletion. That, by the way, works exactly as you are suggesting.
Take a look at the reference guide. The base Store
interface is the one that should be a straight drop-in for the one from Spring Cloud AWS.
Simply cast the return from getResource
to DeletableResource
and call it's delete
to delete the object in S3.
Let me know if this is not clear and I can update with more details.