LiipImagineBundle + KNPGaufrette + VichUploaderBundle + Amazon S3 can't generate thumbnails on S3

1.4k views Asked by At

When trying to use LiipImagineBundle + VichUploaderBundle and Amazon S3, I'm encountering a weird issue. When I upload a file via my Symfony form (using the VichFileType form field), the file is successfully created on Amazon S3 (via Gaufrette). When I display the uploaded file in my twig view, it displays perfectly.

However, when I'm trying to generate a thumbnail of the file (which was uploaded on S3), I get the following error :

The service "liip_imagine.cache.resolver.amazon_s3" has a dependency on a non-existent service "1".

I've followed the documentation : https://symfony.com/doc/2.0/bundles/LiipImagineBundle/cache-resolver/aws_s3.html

Here's my app/config/config.yml file:

# VichUploaderBundle Configuration
vich_uploader:
    db_driver: orm
    twig:      true
    storage:   gaufrette
    mappings:
        campaign_image:
            uri_prefix:         "%aws_base_url%/%aws_bucket_name%/uploads/campaigns"
            upload_destination: campaign_image_fs
            namer:              vich_uploader.namer_uniqid
            delete_on_remove: true
            delete_on_update: true
            inject_on_load: true
        user_identity:
            uri_prefix:         "%aws_base_url%/%aws_bucket_name%/uploads/users"
            upload_destination: user_identity_fs
            namer:              vich_uploader.namer_uniqid
            delete_on_remove: true
            delete_on_update: true
            inject_on_load: true

# LiipImagineBundle Configuration
liip_imagine:
    driver: imagick
    cache: amazon_s3
    resolvers:
        amazon_s3:
            aws_s3:
                client_config:
                    credentials:
                        key:    "%aws_bucket_key%"
                        secret: "%aws_bucket_secret%"
                    region: "%aws_bucket_region%"
                    bucket: "%aws_bucket_name%"
                    version: "2006-03-01"
                bucket: "%aws_bucket_name%"
                cache: true
                get_options:
                    Scheme: https
                put_options:
                    CacheControl: "max-age=86400"
    filter_sets:
        cache: ~
        800x600:
            quality : 93
            filters:
                auto_rotate: ~
                strip: ~
                scale:
                    dim: [ 500, 800 ]

# KnpGaufretteBundle Configuration
knp_gaufrette:
    stream_wrapper: ~
    adapters:
        user_identity_adapter:
            aws_s3:
                service_id: 'app.manager.amazon_s3'
                bucket_name: '%aws_bucket_name%'
                detect_content_type: true
                options:
                    create: true
                    directory: uploads/users
        campaign_image_adapter:
            aws_s3:
                service_id: 'app.manager.amazon_s3'
                bucket_name: '%aws_bucket_name%'
                detect_content_type: true
                options:
                    create: true
                    directory: uploads/campaigns
    filesystems:
        user_identity_fs:
            adapter:    user_identity_adapter
        campaign_image_fs:
            adapter:    campaign_image_adapter

And here is my app/config/services.yml file:

app.manager.amazon_s3:
    class: Aws\S3\S3Client
    factory_class: Aws\S3\S3Client
    factory_method: 'factory'
    arguments:
        -
            version: "2006-03-01"
            region: "%aws_bucket_region%"
            credentials: { "key": "%aws_bucket_key%", "secret": "%aws_bucket_secret%" }

app.imagine.cache.resolver.amazon_s3:
    class: Liip\ImagineBundle\Imagine\Cache\Resolver\AwsS3Resolver
    arguments:
        - "@app.manager.amazon_s3"
        - "%aws_bucket_name%"
        - "public-read" # Aws\S3\Enum\CannedAcl::PUBLIC_READ (default)
        - { Scheme: https }
        - { CacheControl: "max-age=86400" }
    calls:
        - [ setGetOption, [ Scheme, https ] ]
        - [ setPutOption, [ CacheControl, "max-age=86400" ] ]
    tags:
        - { name: "liip_imagine.cache.resolver", resolver: "amazon_s3"}

Any reasons for why I can't get it working?

0

There are 0 answers