S3 Query

The S3 Query step allows you to execute multiple operations on S3-compatible data sources.

Action configuration

To configure the action, you need to select your S3 data source and specify the required settings depending on the S3 action type selected.

The following action types are available:

  • List all files in a bucket

  • Read a file from S3

  • Download a file from S3

  • Generate presigned url for GET/PUT

  • Upload data

  • Copy file to a new location

  • Delete a file from S3

  • Move file to a new location

  • Get tags from a file in S3

  • Delete tags from a file in S3

  • Update tags for a file in S3

If you do not specify the bucket name in the action step, then the one defined in the data source settings will be used.

You can use interpolation to compose bucket names, file names, and other step settings. For example, a file name could be like this:

my-awesome-file-{{new Date().getTime()}}.txt

When reading a file from an S3 bucket, its body will be provided as a Base64-encoded string. You can use the following code in the result mapper to convert it to raw mode:

return {
  ...{{data}},
  Body: atob({{data.BodyBase64}})
};

Use case: Uploading an image using the Upload Data action type

Let's say you want to upload an image from file input to your S3 data source. Here's how you can do that:

  1. Create a new action of the JavaScript Code type and specify the following code:

return new Promise((resolve) => {
  const file = {{ui.imagepicker.value}}; // Replace with your file input component
  const reader = new FileReader();
  reader.readAsBinaryString(file);
  reader.onload = () => {
    resolve(reader.result);
  };
});

This step will read the file from the file input as a binary string.

  1. Now, add the second step to this action and select your S3 data source.

  2. Select Upload data from the S3 action type dropdown and specify all the required fields. Add the {{data}} variable to the Upload data field - it will use the result of the first step.

  1. Finally, run the action.

Last updated

Was this helpful?