# S3 Query

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

## Action configuration

&#x20;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:

```javascript
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:

```javascript
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.

2. Now, add the **second step** to this action and select your S3 data source.
3. 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.

<figure><img src="/files/vowORVFuExXUHoiMnHnX" alt=""><figcaption></figcaption></figure>

4. Finally, run the action.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uibakery.io/reference/working-with-actions/s3-query.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
