Skip to main content

Upload or Download Files to and from S3

Files can be uploaded to Amazon S3 using the S3 plugin and FilePicker Widget. This document presumes you have successfully connected to your S3 instance

Uploading a File

To upload a file

  1. Drag a Filepicker widget onto the canvas.
  2. Create a new S3 query named upload_file to be run onFileSelected.
  3. Select the Create File Action option for the query.
  4. The action should be configured with the bucket name and relative path of the location you want to store the file. ex. images/any intermediate folders not existing are automatically created.
  5. The name of the file should be configured in the file path field. This value can be picked from the Filepicker using JavaScript images/{{ Filepicker1.files[0].name }}
  6. The content can be configured using the entire file object of the Filepicker. {{Filepicker1.files[0]}}
  7. Select a file from the file picker and hit upload.

Downloading Files

To download a file

  1. Drag a Table onto the canvas and name it s3_files.

  2. Create a new S3 query named fetch\_files to fetch all the files in your bucket.

    • Configure it with the List Files action.

    • Set the bucket name from where to fetch the files and run the query

    • Bind the response of the query to the Table using JavaScript in the Table Data Property {{fetch_files.data}}.

      Now your table should list all the files present in your S3 bucket.

Click to expand

  1. Create a new S3 query named read_file to read file data from S3 bucket.
    • Configure it with the Read File action.
    • Set the bucket name from where to fetch the file
    • Set path to the file path selected in the table using the JS expression {{s3_files.selectedRow.fileName}}

Click to expand

  1. To download the file selected in the table

    • Click the JS button next to onRowSelected Action and write the

      following JavaScript query:

    {{read_file.run(
    ()=>{download(atob(read_file.data.fileData),s3_files.selectedRow.fileName.split("/").pop())})}}
    • Click any row in table s3_files to download the corresponding file from your S3 bucket.