1

在尝试使用 LiipImagineBundle + VichUploaderBundle 和 Amazon S3 时,我遇到了一个奇怪的问题。

当我通过我的 symfony 表单(使用 VichFileType 表单字段)上传文件时,该文件在 Amazon S3 上成功创建(通过 Gaufrette)。

当我在树枝视图中显示上传的文件时,它会完美显示。

但是,当我尝试生成文件的缩略图(在 S3 上上传)时,出现以下错误:

服务“liip_imagine.cache.resolver.amazon_s3”依赖于不存在的服务“1”。

我遵循了文档:https ://symfony.com/doc/2.0/bundles/LiipImagineBundle/cache-resolver/aws_s3.html

这是我的app/config/config.yml文件:

# 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

这是我的 app/config/services.yml 文件:

    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"}

为什么我不能让它工作的任何原因?

任何帮助表示赞赏!

谢谢

4

1 回答 1

0

我不知道我是否会说得好,但就是这样。

重点是 Vich Uploader 在您的树枝中提供给 LiipImagine 的图像链接。Liip 想象将尝试通过调用过滤器的加载器获取图像。

请注意,您没有定义该加载器,因此它将是默认加载器。检查这里 [https://github.com/liip/LiipImagineBundle#data-roots]

在本地,这里是工作配置,以实现您想要做的事情: VichUploader + KnpGaufrette + LiipImagine 捆绑到 S3 在本地工作

如果您终于通过了,请反馈给我们!

于 2021-10-01T08:53:56.647 回答