diff --git a/src/main/java/io/kestra/plugin/aws/s3/ActionInterface.java b/src/main/java/io/kestra/plugin/aws/s3/ActionInterface.java index 0df884e5..4c3d4fe5 100644 --- a/src/main/java/io/kestra/plugin/aws/s3/ActionInterface.java +++ b/src/main/java/io/kestra/plugin/aws/s3/ActionInterface.java @@ -7,14 +7,14 @@ public interface ActionInterface { @Schema( - title = "The action to perform on the retrieved files." + title = "The action to perform on the retrieved files. If using 'NONE' make sure to do some actions on the files to avoid infinite triggering." ) @PluginProperty(dynamic = true) @NotNull ActionInterface.Action getAction(); @Schema( - title = "The destination bucket and key." + title = "The destination bucket and key for `MOVE` action." ) @PluginProperty(dynamic = true) Copy.CopyObject getMoveTo(); diff --git a/src/main/java/io/kestra/plugin/aws/s3/Trigger.java b/src/main/java/io/kestra/plugin/aws/s3/Trigger.java index a3e7b2d4..a63af6ab 100644 --- a/src/main/java/io/kestra/plugin/aws/s3/Trigger.java +++ b/src/main/java/io/kestra/plugin/aws/s3/Trigger.java @@ -67,6 +67,41 @@ " moveTo: ", " key: archive", } + ), + @Example( + title = "Wait for a list of files on a s3 bucket and iterate through the files. Delete files manually after processing to prevent infinite triggering.", + full = true, + code = { + "id: s3-listen", + "namespace: io.kestra.tests", + "", + "tasks:", + " - id: each", + " type: io.kestra.core.tasks.flows.EachSequential", + " tasks:", + " - id: return", + " type: io.kestra.core.tasks.debugs.Return", + " format: \"{{ taskrun.value }}\"", + " - id: delete", + " type: io.kestra.plugin.aws.s3.Delete", + " accessKeyId: \"\"", + " secretKeyId: \"\"", + " region: \"eu-central-1\"", + " bucket: \"my-bucket\"", + " key: \"{{ taskrun.value }}\"", + " value: \"{{ trigger.objects | jq('.[].key') }}\"", + "", + "triggers:", + " - id: watch", + " type: io.kestra.plugin.aws.s3.Trigger", + " interval: \"PT5M\"", + " accessKeyId: \"\"", + " secretKeyId: \"\"", + " region: \"eu-central-1\"", + " bucket: \"my-bucket\"", + " prefix: \"sub-dir\"", + " action: NONE", + } ) } ) @@ -134,7 +169,7 @@ public Optional evaluate(ConditionContext conditionContext, TriggerCo .build(); List.Output run = task.run(runContext); - if (run.getObjects().size() == 0) { + if (run.getObjects().isEmpty()) { return Optional.empty(); }