Skip to content

Latest commit

 

History

History
60 lines (37 loc) · 2.7 KB

how-to-upload-to-s3.md

File metadata and controls

60 lines (37 loc) · 2.7 KB

Upload / Download Files 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

  1. Select the Create File Action option for the query.
  2. 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 will be automatically created.
  3. The name of the file should be configured in the file path field. This value can be picked from the Filepicker using javascriptimages/{{ Filepicker1.files[0].name }}
  4. The content can be configured using the data property of the Filepicker. {{Filepicker1.files[0].data}}
  5. Select a file from the file picker and hit upload

Click to expand

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 javascript expression {{s3_files.selectedRow.fileName}}

Click to expand

  1. To download the file selected in the table

    • Click on 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.