Display AWS S3 files from signed URLs
Last updated
Last updated
This example explains how to display pictures stored in an AWS S3 bucket, from signed URLs.
Below we have a collection places
with a field pictures
which is an array of strings containing the names of files stored in an S3 bucket on AWS.
We use then a smart field s3Pictures
that is an array of return values from calls made to S3 to get signed URLs from the files present in pictures
field.
An admin backend running on forest-express-sequelize
An AWS S3 bucket with access credentials
The aws-sdk npm package
This directory contains the places.js
file where the places
model is declared.
This directory contains an s3-helper.js
file, where the method to get the signed URL from S3 is defined. We use the aws-sdk
npm package to connect to the bucket storing the pictures.
You need to configure your AWS credentials inside your app to get access to your bucket. You can read more about it in the AWS documentation here.
This directory contains the places.js
file where the smart field s3Pictures
is declared.
In the get function, we iterate on the pictures array to get the signed URL for each file name and then return an array with the signed URLs.
You can then use the file viewer widget to preview the pictures.