简体   繁体   English

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

[英]Sonata media bundle - pdf upload shows ROLE Error

I have a working image uploader with the mediabundle, but it looks like the fileupload doesn't work. 我有一个带有mediabundle的工作图像上传器,但看起来fileupload不起作用。

i tried to upload a pdf file , and got the following error: 我试图上传pdf文件,并收到以下错误:

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

I am 100% sure that I have the right admin roles. 我100%确定我有合适的管理员角色。 After a deep search in the code I found, that the /sonata-project/doctrine-phpcr-admin-bundle/Model/ModelManager.php create function drops an error: 深入搜索我发现的代码后,/ sonata-project/doctrine-phpcr-admin-bundle/Model/ModelManager.php创建函数会丢失一个错误:

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

I think my config.yml should be fine : 我认为我的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

when I tried to add locally as you can see the config above it still didn't work. 当我尝试在本地添加,因为你可以看到上面的配置它仍然无法正常工作。 Neuther on the sonata.media.filesystem.s3 Could the missing default pdf template image should cause the issue? 在sonata.media.filesystem.s3上的Neuther可能缺少的默认pdf模板图像会导致问题吗? Or has someone a similar issue before? 或者之前有某个类似的问题?

The resizer expected width and height. 缩放器预期宽度和高度。 Even if the resizer is not necessary for pdf, it should have been in Application\\Sonata\\MediaBundle\\PHPCR\\Media class: 即使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;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM