2

尝试上传图像后,我收到以下错误消息:

An exception has been thrown during the rendering of a template ("Unable to retrieve the download security : ").

此错误发生在“创建”之后,位于以下 URI:

/web/app_dev.php/en/admin/sonata/media/media/cms/media/58c1be25e1d27/edit?context=default&hide_context=0

图片已上传、裁剪等,但我认为文档没有正确保存到数据库中。

这是我的配置:

“奏鸣曲项目/媒体包”:“^3.5”,

“教义/phpcr-odm”:“^1.4”,

“奏鸣曲项目/doctrine-phpcr-admin-bundle”:“^2.0@dev”,

配置.yml

sonata_media:
    # if you don't use default namespace configuration
    class:
        media: Application\Sonata\MediaBundle\PHPCR\Media
        gallery: Application\Sonata\MediaBundle\PHPCR\Gallery
        gallery_has_media: Application\Sonata\MediaBundle\PHPCR\alleryHasMedia
    db_driver: doctrine_phpcr # or doctrine_mongodb, doctrine_phpcr it is mandatory to choose one here
    default_context: default # you need to set a context
    contexts:
        default:  # the default context is mandatory
            providers:
                - sonata.media.provider.dailymotion
                - sonata.media.provider.youtube
                - sonata.media.provider.image
                - sonata.media.provider.file
                - sonata.media.provider.vimeo

            formats:
                small: { width: 100 , quality: 70}
                big:   { width: 500 , quality: 70}

    cdn:
        server:
            path: /uploads/media # http://media.sonata-project.org/

    filesystem:
        local:
            directory:  "%kernel.root_dir%/../web/uploads/media"
            create:     false


doctrine_phpcr:
    # configure the PHPCR session
    session:
        backend:   '%phpcr_backend%'
        workspace: '%phpcr_workspace%'
        username:  '%phpcr_user%'
        password:  '%phpcr_pass%'
    odm:
        auto_mapping: true
        auto_generate_proxy_classes: '%kernel.debug%'
        locales:
            en: [de, fr]
            de: [en, fr]
            fr: [en, de]
        mappings:
            #SonataMediaBundle:
            #    prefix: Sonata\MediaBundle\PHPCR
            ApplicationSonataMediaBundle:
                prefix: Application\Sonata\MediaBundle\PHPCR

初始化器

app.phpcr.initializer:
    class: Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer
    arguments:
        - SonataMediaBundle
        - ["/cms/media"]
    tags:
        - { name: doctrine_phpcr.initializer }

我正在使用默认的自动生成的 PHPCR 文档和配置。

4

1 回答 1

1

我有同样的问题,但我使用的是 Doctrine 而不是 PHPCR。

就我而言,我在管理员的上传表单中选择了错误的媒体上下文

如果您选择错误的(不存在的)上下文,该文件似乎是不可编辑的。

->add('media', 'sonata_type_model_list', array('required' => false), array(
                        'link_parameters' => array(
                            'context'  => 'Context name', // Important: You have to select the context name and not the context code!
                            'filter'   => array('category' => array('value' => 'Dummy category name')),
                            'provider' => 'sonata.media.provider.file',
                        )
                    ))
于 2017-06-29T16:42:49.147 回答