using aws s3 outbound adapter in spring boot application,trying to upload files in s3 bucket. would like to check if bucket available before uploading file. if bucket is not available need to throw error.
suggest on this.
<int-aws:s3-outbound-gateway id="FileChannelS3"
request-channel="filesOutS3CChainChannel"
reply-channel="filesArcChannel"
transfer-manager="transferManager"
bucket-expression="headers.TARGET_BUCKET"
command="UPLOAD">
<int-aws:request-handler-advice-chain>
<ref bean="retryAdvice" />
</int-aws:request-handler-advice-chain>
</int-aws:s3-outbound-gateway>
You can configure an
S3RemoteFileTemplate
bean and use itsexists()
API in the<filter>
:UPDATE
Sorry, missed the fact that you need to check existence of the
bucket
, not an object inside.For that purpose you need to use an Amazon API directly:
where an
amazonS3
is a bean for thecom.amazonaws.services.s3.AmazonS3
client.