Sylius: How to configure KnpGaufrette to upload images onto AWS S3?

Created on 9 Jul 2019  路  4Comments  路  Source: Sylius/Sylius

Sylius docs version: 1.4

I'm trying to configure Sylius in a way that images will be uploaded onto AWS S3. Sylius uses LiipImageBundle under the hood, so I was following their Docs to set everything up.

However, after this configuration, nothing happens. When I submit an image in the backend, it seems to be sent to nowhere. No error message is logged. Not a single line appears in the application logfile as well. When I remove these settings (or at minimal the line cache: artist_photos), everything works like before writing images into ./web/media/cache.

This is my configuration:

config.yml:

parameters:
    locale: en_US
    amazon.s3.key:     "yyyyyy"
    amazon.s3.secret:  "xxxxxxxxx"
    amazon.s3.bucket:  "test.xxxxxx.com"
    amazon.s3.region:  "eu-central-1"
    amazon.s3.version: "2006-03-01"



liip_imagine:
    resolvers:
        default:
            web_path:
                web_root: "%kernel.project_dir%/web"
                cache_prefix: "media/cache"


        artist_photos:
            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"

    cache: artist_photos

    filter_sets:
        cache: ~
        my_thumb:
            cache: artist_photos
            filters:
            # the filter list

services.yml:

app.amazon_s3:
    class: Aws\S3\S3Client
    factory: [Aws\S3\S3Client, factory]
    arguments:
        -
            credentials: { key: "%amazon.s3.key%", secret: "%amazon.s3.secret%" }
            region: "%amazon.s3.region%"
            version: "%amazon.s3.version%"

app.imagine.cache.resolver.amazon_s3:
    class: Liip\ImagineBundle\Imagine\Cache\Resolver\AwsS3Resolver
    arguments:
        - "@app.amazon_s3"
        - "%amazon.s3.bucket%"
    tags:
        - { name: "liip_imagine.cache.resolver", resolver: "amazon_s3" }

What do I miss here?

Most helpful comment

All 4 comments

This config from @vvasiloi works like a charm! Many thanks for this!

@itinance you're welcome! I hope you will find time to contribute this to docs as you suggested.

Yes, will definitely do. I have already drafted a little bit. Will hopefully complete during the week

Was this page helpful?
0 / 5 - 0 ratings