This guide demonstrates how to configure file upload and download operations using the Amazon S3 data source in ToolJet. Learn how to use Upload Object, generate signed URLs, and manage S3 buckets directly from your applications.
Before building the UI, check out the **[docs for AWS S3 data source](/docs/data-sources/s3)** to learn about setting up AWS S3 and adding the data source.
This query will fetch the list of all the buckets in your S3. Just create a new query, select AWS S3 data source, and choose **List buckets** operation. Name the query **get_buckets** and click **Save**.
- **Schema**: Enable the **Dynamic Options** and enter the code mentioned below. Here, we are mapping the data returned by the query as the returned data is array of objects.
This query will list all the objects inside the selected Bucket in dropdown. Select **List objects in a bucket** operation, enter `{{components.dropdown1.value}}` in the Bucket field - this will dynamically get the field value from the selected option in dropdown.
- Add a **Action button**: Set button text to **Copy signed URL**, Add a handler to this button for **On Click** event and Action to **Copy to clipboard**, in the text field enter `{{queries.download.data.url}}` - this will get the download url from the **download** query that we will create next.
Create a new query and select **Signed URL for download** operation. In the Bucket field, enter `{{components.dropdown1.value}}` and in Key enter `{{components.table1.selectedRow.Key}}`.
Edit the **properties** of the table, add a Event handler for running the `download` query for `Row clicked` event. This will generate a signed url for download every time a row is clicked on the table.
- Change the **Accept file types** to `{{"application/pdf"}}` for the picker to accept only pdf files or even `{{"image/*"}}` for the picker to accept only image files. In the screenshot below, we have set the accepted file type property to `{{"application/pdf"}}` so it will allow to select only pdf files.
- Add an Event Handler : Go to the **advanced** tab of the **upload_to_S3** query and add an event **Query Success**, an add an action to a **Run Query** and select the query **list_objects**, so that whenever a file is uploaded the tabled is refreshed.
File types must be valid **[MIME](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types)** type according to input element specification or a valid file extension.
To accept any/all file type(s), set `Accept file types` to an empty value.