freedomsex/photo-upload-bundle

安装: 1

依赖: 0

建议: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 3

类型:symfony-bundle


README

FreedomSex 项目提供的组件。

提供图像文件下载服务。文件的实体接口。预设路径和文件命名配置。使用策略可能因项目而异。

默认配置

photo_upload:
    width: 600  # max width
    height: 800 # max height
    quality: 80 # jpeg quality 
    namer: 'upload_file_namer'

基本用法

# PhotoController

use FreedomSex\PhotoUploadBundle\Services\FileUploader;
use FreedomSex\PhotoUploadBundle\Entity\FileInterface;

    public $fileUploader;

    public function __construct(FileUploader $fileUploader)
    {
        $this->fileUploader = $fileUploader;
    }

    public function upload(UploadedFile $file)
    {
        $entity = new Photo(); # implements FileInterface
        $this->fileUploader->upload($file, $entity);
    }