Marketplace Apps
Use secure files from AWS S3 in your website or apps with Agility content.
Description: This app enables you to securely store and manage files in Agility CMS using AWS S3. By integrating AWS S3, you can leverage its robust security features and scalability to handle your file storage needs efficiently.
Setup Instructions:
Configuration in Agility CMS:
Code Example:
To deliver files to the frontend using a pre-signed URL, you can use the following code snippet:
//use env vars for the bucket and credentials, or authenticate another way
const bucketName = process.env.AWS_S3_BUCKET_NAME || ""
const region = process.env.AWS_S3_REGION || ""
const accessKeyId = process.env.AWS_S3_ACCESS_ID || ""
const secretAccessKey = process.env.AWS_S3_SECRET_KEY || ''
const s3Config: S3ClientConfig = {
credentials: {
accessKeyId,
secretAccessKey,
},
region,
};
//pull the filename from your agility content item value
const s3Client = new S3Client(s3Config);
const command = new GetObjectCommand({ Bucket: bucketName, Key: filename });
const signedUrlRes = await getSignedUrl(s3Client, command, { expiresIn: 10 });
//redirect to the signed URL
return Response.redirect(signedUrlRes, 302)
This code generates a pre-signed URL that allows secure access to a specific object in your S3 bucket for a limited time. You can use this URL in your frontend to enable users to download files securely.