How to store images on AWS-S3 automatically?¶
Instructions:¶
First you need to ensure that the official AWS-S3 SDK
for PHP is installed:
composer require aws/aws-sdk-php league/flysystem-aws-s3-v3
1. Configure Flysystem AWS S3 Adapter¶
Place this file under config/packages/flysystem.yaml
:
# config/packages/flysystem.yaml
flysystem:
storages:
sylius.storage:
adapter: 'aws'
options:
client: Aws\S3\S3Client
bucket: "%aws.s3.bucket%"
prefix: "media/image"
streamReads: true
2. Configure Liip-Imagine:¶
Add this file under config/packages/liip_imagine.yaml
in order to make Liip-Imagine aware of AWS S3 storage:
# config/packages/liip_imagine.yaml
liip_imagine:
loaders:
aws_s3:
flysystem:
filesystem_service: sylius.storage
resolvers:
aws_s3:
aws_s3:
client_config:
credentials:
key: "%aws.s3.key%"
secret: "%aws.s3.secret%"
region: "%aws.s3.region%"
version: "%aws.s3.version%"
bucket: "%aws.s3.bucket%"
get_options:
Scheme: https
put_options:
CacheControl: "max-age=86400"
cache_prefix: media/cache
data_loader: aws_s3
cache: aws_s3