0

我有一個工作的圖像上傳與mediabundle,但它看起來像fileupload不起作用。索納塔媒體包 - pdf上傳顯示角色錯誤

我試圖上傳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模板圖像會導致問題嗎?或者有人有類似的問題嗎?

回答

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