Upload Images to S3 Using Camera
This page provides steps to upload images using the Camera widget to the S3 datasource.
Prerequisites
- An Amazon S3 bucket in one of the AWS Regions.
- App connected to an S3 datasource.
Set up upload query
To upload an image or a video to Amazon S3, follow these steps:
Drag and drop the Camera widget onto the canvas.
In Queries/JS, click the + Add a new query/JS Object.
Select your S3 datasource.
Select Create a new file from Commands.
In Bucket Name, enter the name of the Amazon S3 bucket.
In File Path, enter the path of the location you want to store the file. For example,
images/camera_uploads
. Appsmith automatically creates intermediate folders if they don't exist.Select Base64 from File Data Type to upload data from the camera widget.
In Expiry Duration of Signed URL (Minutes), enter an expiration time for the signed URL. A signed URL has a maximum expiration date of one week.
In Content, fetch data from the Camera widget using the following code:
{
"data": "{{Camera1.imageDataURL}}"
}Once all the required parameters have been added, set the OnImageCapture event on the Camera widget's property pane to execute the S3 query. Query execution occurs when you capture and save an image. To see the uploaded media, visit the S3 console.