Hi I want to copy an existing object to same path in AWS S3 and I am getting following exception
This copy request is illegal because it is trying to copy an object to itself without changing the object's metadata, storage class, website redirect location or encryption attributes
I am using Apache camel S3, how can i resolve this. After searching, i found there is a request header which we can use to replace the existing file but it is not working
// multiple other attempts also present, I am not sure which header will work
exchange.`in`.headers[AWS2S3Constants.METADATA] = mutableMapOf(
"x-amz-metadata-directive" to "REPLACE",
"x-amz-meta-directive" to "REPLACE",
"metadata-directive" to "REPLACE",
"MetadataDirective" to "REPLACE"
)
I have logged in the request.
Sending Request: DefaultSdkHttpFullRequest(httpMethod=PUT, protocol=https, host=, port=443, encodedPath=, headers=[amz-sdk-invocation-id, User-Agent, x-amz-copy-source, x-amz-meta-directive, x-amz-meta-metadata-directive, x-amz-meta-MetadataDirective, x-amz-meta-x-amz-metadata-directive], queryParameters=[])
But it is not working. how can i copy an existing object to same path without getting this error.
I end up changing the filename by suffixing it with a timestamp. Now I am no longer getting the error.
But I think, there should be some way to copy existing objects via API, since I am able to do same via aws-cli
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With