S3 query

The S3 step allows you to execute multiple operations on S3-compatible data sources. If the bucket name is not specified in the action step, 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 instance, 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}})
};

Uploading an image from file input using S3 Upload Data step

In order to upload an image from file input using the S3 Upload data step, you will need to create a multi-step action.

Your first step should read file from a file input as a binary string. For this purposes, you can use the Custom JavaScript code step and 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);
  };
});

The next s3 upload data step should use the {{data}} from this step and set the appropriate file content type (e.g. image/png):

Last updated