2
votes

After attempting to upload an image, i get the following error message:

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

This error occurs after the "create", at the following URI:

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

The image is uploaded, croped and so on, but i dont think the Document is getting saved properly to the database.

Here are my configurations:

"sonata-project/media-bundle": "^3.5",

"doctrine/phpcr-odm": "^1.4",

"sonata-project/doctrine-phpcr-admin-bundle": "^2.0@dev",

config.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

Initalizer

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

And I am using the default auto-generated PHPCR Documents & Configuration.

1
I have the same issue with SonataMediaBundle 3.3.1 and using Doctrine ORM 2.5.5 With commenting the SonataMediaBundle:MediaAdmin:edit.html.twig line 75, the problem don't show. But that's not a clean solution...Naelyth
Give up on it, it is horrible, the whole library is buggy as helluser2559108

1 Answers

1
votes

I have the same issue but I'm using Doctrine instead of PHPCR.

In my case I've select the wrong media context in upload form in Admin

It seems if you select wrong (non existing) context the file is not editable.

->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',
                        )
                    ))