I currently have a problem for the configuration of liip_imagine. My setup :
I first installed vichuploader with flysystem, and it works, after that I trying to add liipimagine, but the url generated is not on my aws s3.
website domain : mywebsite.com
s3 domain : asset.mywebsite.com
url generated from liipimagine : mywebsite.com/media/cache/resolve/md/facility/photo/big-img-65d760d9afe9a372425826.jpg
This parts working well, I can upload image and display it on my twig :
vich_uploader.yaml :
vich_uploader:
db_driver: orm
storage: flysystem
metadata:
type: attribute
mappings:
facility_photo:
upload_destination: s3.facility_photo
uri_prefix: '%asset_s3_url%/facility/photo'
namer: Vich\UploaderBundle\Naming\SmartUniqueNamer
inject_on_load: false
delete_on_update: true
delete_on_remove: true
flysystem.yaml :
flysystem:
storages:
s3.facility_photo:
adapter: 'aws'
visibility: public
options:
client: 'Aws\S3\S3Client'
bucket: '%amazon_s3_bucket%'
prefix: 'facility/photo'
streamReads: true
services.yaml :
services:
Aws\S3\S3Client:
arguments:
-
version: "%amazon_s3_version%"
region: "%amazon_s3_region%"
endpoint: "https://s3.%amazon_s3_region%.amazonaws.com"
credentials:
key: "%amazon_s3_key%"
secret: "%amazon_s3_secret%"
But so I added liipimagine :
liip_imagine:
resolvers:
cache_resolver_aws_s3:
aws_s3:
client_config:
credentials:
key: "%amazon_s3_key%"
secret: "%amazon_s3_secret%"
region: "%amazon_s3_region%"
version: "%amazon_s3_version%"
bucket: "%amazon_s3_bucket%"
get_options:
Scheme: https
put_options:
CacheControl: "max-age=86400"
loaders:
loader_aws_s3:
flysystem:
filesystem_service: 's3.facility_photo'
filter_sets :
cache: ~
md:
data_loader: loader_aws_s3
cache: cache_resolver_aws_s3
quality: 100
filters:
thumbnail: { size: [120, 90], mode: outbound }
I tried to add the filter 'md' in my twig :
<img src="{{ vich_uploader_asset(photo, 'imageFile', 'App\\Entity\\PhotoFacility') | imagine_filter('md') }}" />
He will not found the url from s3, but on my website domain : mywebsite.com/media/cache/resolve/md/facility/photo/big-img-65d760d9afe9a372425826.jpg
Did I forget some configuration ? I followed the liipimage docs
Help would be welcome, thanking you in advance for your collaboration
I found my mistake, it wasn't a liipimagine configuration issue, but a flysystem.
In league/flysystem package, league/flysystem-aws-s3-v3/AwsS3V3Adapter.php, I I checked the fetchFileMetadata()
function, the value of 'Key' generated in :
$arguments = ['Bucket' => $this->bucket, 'Key' => $this->prefixer->prefixPath($path)];
facility/photo/facility/photo/big-img-65d760d9afe9a372425826.jpg
(duplicate prefix 'facility/photo')
So the $result = $this->client->execute($command);
generate an error, because the request respond an error.
To fix it, I just had to remove the prefix from flysystem.yaml
:
s3.facility_photo:
adapter: 'aws'
visibility: public
options:
client: 'Aws\S3\S3Client'
bucket: '%amazon_s3_bucket%'
# prefix: 'facility/photo'
streamReads: true
Because 'facility/photo' was already generated by the vich_uploader.yaml
:
facility_photo:
upload_destination: s3.facility_photo
uri_prefix: '%asset_s3_url%/facility/photo'
namer: Vich\UploaderBundle\Naming\SmartUniqueNamer
inject_on_load: false
delete_on_update: true
delete_on_remove: true
After that, liipimagine had a functional response, so it generated the right link using my s3.
Feel free to edit my post to correct my English mistakes ! :)