[
https://issues.apache.org/jira/browse/CAMEL-17025?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17949508#comment-17949508
]
Bradley McKinley edited comment on CAMEL-17025 at 5/5/25 5:39 PM:
------------------------------------------------------------------
The title of the ticket is misleading as it implies that you cannot specify the
same bucket when selecting moveAfterRead. However, the main issue of the key
of the moved object being ugly is accurate IMHO, and I suggest a slightly
different solution to the one that described that will preserve existing
behavior as the default and requires a smaller code change. New behavior would
work as follows:
Create a 'removePrefixOnMove' flag that defaults to false. When set to true,
whatever string that was specified as a prefix will be stripped from the new
key. For example:
_Original bucket=myBucket_
_prefix= /path/to/folder/run_
_moveAfterRead=true_
_removePrefixOnMove=true_
_destinationBucket=myBucket_
_destinationBucketPrefix=/path/to/folder/done_
With a configuration like this, if the system finds an object with the
following key:
/path/to/folder/run/subfolder/test.txt
it will create a copy of the object with a key of:
/path/to/folder/done/subfolder/test.txt
but if removePrefixOnMove is false, the behavior is unchanged and the key is:
_/path/to/folder/done/path/to/folder/run/subfolder/test.txt_
was (Author: JIRAUSER309590):
The title of the ticket is misleading as it implies that you cannot specify the
same bucket when selecting moveAfterRead. The main issue of the key of the
moved object being ugly is accurate IMHO, and I suggest a slightly different
solution to the one that described that will preserve existing behavior as the
default and requires a smaller code change. New behavior would work as follows:
Create a 'removePrefixOnMove' flag that defaults to false. When set to true,
whatever string that was specified as a prefix will be stripped from the new
key. For example:
_Original bucket=myBucket_
_prefix= /path/to/folder/run_
_moveAfterRead=true_
_removePrefixOnMove=true_
_destinationBucket=myBucket_
_destinationBucketPrefix=/path/to/folder/done_
With a configuration like this, if the system finds an object with the
following key:
/path/to/folder/run/subfolder/test.tx
it will create a copy of the object with a key of:
/path/to/folder/done/subfolder/test.tx
but if removePrefixOnMove is false, the behavior is unchanged and the key is:
_/path/to/folder/done/path/to/folder/run/subfolder/test.txt_
> camel-aws-s3 - Allow moveAfterRead in same bucket for AWS S3 consumer
> ---------------------------------------------------------------------
>
> Key: CAMEL-17025
> URL: https://issues.apache.org/jira/browse/CAMEL-17025
> Project: Camel
> Issue Type: Improvement
> Components: camel-aws, camel-aws2
> Reporter: Fabio Zani
> Assignee: Andrea Cosentino
> Priority: Minor
> Fix For: 4.x
>
> Attachments: camel-17025-patch.txt
>
>
> Using the AWS2 S3 component it would be nice to have a way to move a file
> inside a different subfolder in the same bucket after reading it.
> h1. AS IS
> With the current implementation, the _moveAfterRead_ option requires to
> specify the destination bucket and eventually a prefix and/or suffix.
> As it is not intended for moving into a different folder in the same bucket,
> trying to specify the original bucket as destination and the path to the
> subfolder as a prefix has an _ugly_ result, as shown in the following example.
> Original bucket: myBucket
> File path: /path/to/foloder/run/test.txt
> _moveAfterRead=true_
> _destinationBucket=myBucket_
> _destinationBucketPrefix=/path/to/folder/done_
> Result: file is moved, but file key is
> _/path/to/folder/done/path/to/folder/test.txt_
> h1. TO BE
> Allow moving the file under a different folder in the same bucket.
> An option would be to recognize if the destination bucket is the same as the
> original bucket, requiring the destinationBuketPrefix to be set, moving the
> file (with the filename extracted from the _CamelAwsS3Key_) under the
> specified prefix.
> Another option would be to introduce a new option designed specifically to
> move the file within the same bucket. The moveAfterRead option would then
> require either the _destinationBucket_ option or the
> _destinationSubfolderPrefix_ to be set.
> In case the second solution is chosen, the _destinationBucketSuffix_ option
> could be renamed in _destinationSuffix_ to be used with both moving within
> the bucket or to another bucket or a new option
> (_destinationSubfolderSuffix_) should be introduced.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)