Sonata媒体包 - pdf上传显示ROLE错误

时间:2016-06-29 14:13:49

标签: symfony sonata-admin symfony-sonata symfony-cmf sonata-media-bundle

我有一个带有mediabundle的工作图片上传器,但看起来文件上传不起作用。

我试图上传pdf文件,并收到以下错误:

The media can be retrieved by users with the following roles : ROLE_SUPER_ADMIN, ROLE_ADMIN. 

我100%确定我有合适的管理员角色。深入搜索我发现的代码后,/ sonata-project/doctrine-phpcr-admin-bundle/Model/ModelManager.php创建函数会丢失错误:

String(83) "Field "width" of class "Application\Sonata\MediaBundle\PHPCR\Media" is not nullable"

我认为我的config.yml应该没问题:

 providers:
    file:
        service:    sonata.media.provider.file
        resizer:    false
        filesystem: sonata.media.filesystem.local
        thumbnail:  sonata.media.thumbnail.format
        allowed_extensions: ['pdf', 'txt', 'rtf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pttx', 'odt', 'odg', 'odp', 'ods', 'odc', 'odf', 'odb', 'csv', 'xml']
        allowed_mime_types: ['application/pdf', 'application/x-pdf', 'application/rtf', 'text/html', 'text/rtf', 'text/plain']


    image:
        filesystem: sonata.media.filesystem.s3
        allowed_extensions: ['jpg', 'png', 'jpeg', 'gif']
        allowed_mime_types: ['image/pjpeg', 'image/jpeg', 'image/png', 'image/x-png', 'image/gif']
        resizer: sonata.media.resizer.custom

当我尝试在本地添加时,因为您可以看到上面的配置它仍然无法正常工作。 Neuther在sonata.media.filesystem.s3上 丢失的默认pdf模板图像是否应该导致问题?或者之前有某个类似的问题?

1 个答案:

答案 0 :(得分:0)

缩放器预期的宽度和高度。即使pdf不需要大小调整器,它也应该在Application \ Sonata \ MediaBundle \ PHPCR \ Media类中:

<?php
namespace Application\Sonata\MediaBundle\PHPCR;
use Sonata\MediaBundle\PHPCR\BaseMedia as BaseMedia;
/**
 * Media class
 *
 * @see https://sonata-project.org/bundles/easy-extends
 * @see http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/index.html
 */
class Media extends BaseMedia
{
    /**
     * @var integer
     */
    protected $id;
    /**
     * @var integer
     */
    protected $width = 0;
    /**
     * @var integer
     */
    protected $height = 0;
    /**
     * Get ID
     *
     * @return integer $id
     */
    public function getId()
    {
        return $this->id;
    }
}