Use VichUploaderBundle with flysystem for resources

pull/3016/head
Julio 5 years ago
parent 3540447f0e
commit d8d0e7ff5e
  1. 5
      composer.json
  2. 1
      config/bundles.php
  3. 4
      config/packages/liip_imagine.yaml
  4. 40
      config/packages/oneup_flysystem.yaml
  5. 13
      config/packages/oneup_uploader.yaml
  6. 3
      config/services.yaml
  7. 6
      src/CoreBundle/Controller/ResourceDownloadController.php
  8. 2
      src/CoreBundle/Resources/views/Resource/upload.html.twig

@ -102,7 +102,7 @@
"stephpy/timeline-bundle": "~3.0",
"stof/doctrine-extensions-bundle": "~1.3",
"sunra/php-simple-html-dom-parser": "~1.5.0",
"sylius/resource-bundle": "~1.5",
"sylius/resource-bundle": "~1.6",
"friendsofsymfony/jsrouting-bundle": "~2.0",
"gedmo/doctrine-extensions": "~2.4",
@ -159,7 +159,8 @@
"simplethings/entity-audit-bundle": "^1.0",
"masterminds/html5": "2.*",
"league/csv": "^9.1",
"brumann/polyfill-unserialize": "^1.0"
"brumann/polyfill-unserialize": "^1.0",
"vich/uploader-bundle": "1.8.*"
},
"config": {
"component-dir": "public/assets"

@ -78,4 +78,5 @@ return [
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
HtmlSanitizer\Bundle\HtmlSanitizerBundle::class => ['all' => true],
Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true],
];

@ -8,9 +8,9 @@ liip_imagine:
web_path:
cache_prefix: '../var/cache/resource'
loaders:
default:
resources:
filesystem:
data_root: '%kernel.root_dir%/../var/upload/resource'
data_root: '%kernel.root_dir%/../var/upload/resource2'
filter_sets:
# Chamilo filters
hotspot_question:

@ -1,43 +1,11 @@
oneup_flysystem:
adapters:
courses_adapter:
local:
directory: '%kernel.project_dir%/var/courses'
home_adapter:
local:
directory: '%kernel.project_dir%/var/home'
resource_adapter:
local:
directory: '%kernel.project_dir%/var/upload/resource'
# resource_private_adapter:
# local:
# directory: '%kernel.project_dir%/var/upload/resource'
#
# resource_public_adapter:
# local:
# directory: '%kernel.project_dir%/public/upload/resource'
directory: '%kernel.project_dir%/var/upload/resource2'
filesystems:
courses:
adapter: courses_adapter
visibility: private
cache: ~
alias: ~
mount: ~
home:
adapter: home_adapter
visibility: private
alias: home_filesystem
resource:
resources:
adapter: resource_adapter
# resource_public:
# adapter: resource_public_adapter
#
# resource_private:
# adapter: resource_private_adapter
mount: resources_fs
visibility: private

@ -1,24 +1,13 @@
# Read the documentation: https://github.com/1up-lab/OneupUploaderBundle/blob/master/Resources/doc/index.md
oneup_uploader:
mappings:
courses:
#frontend: dropzone # or any uploader you use in the frontend
#frontend: blueimp
frontend: custom
storage:
type: flysystem
filesystem: oneup_flysystem.courses_filesystem
root_folder: true
custom_frontend:
class: Chamilo\CoreBundle\Controller\ResourceUploaderController
name: courses
resource:
#frontend: dropzone # or any uploader you use in the frontend
#frontend: blueimp
frontend: custom
storage:
type: flysystem
filesystem: oneup_flysystem.resource_filesystem
filesystem: oneup_flysystem.resources_filesystem
root_folder: true
custom_frontend:
class: Chamilo\CoreBundle\Controller\ResourceUploaderController

@ -30,6 +30,9 @@ services:
exclude: '../src/PageBundle/{Entity,Migrations,Tests}'
public: true
Vich\UploaderBundle\Naming\SubdirDirectoryNamer:
public: true
Chamilo\ThemeBundle\:
autowire: true
resource: '../src/ThemeBundle/*'

@ -35,7 +35,7 @@ class ResourceDownloadController extends BaseController
//$helper = $this->container->get('oneup_uploader.templating.uploader_helper');
//$endpoint = $helper->endpoint('courses');
return $this->render(
'@ChamiloTheme/Resource/upload.html.twig',
'@ChamiloCore/Resource/upload.html.twig',
[
'identifier' => $id,
'type' => $type,
@ -58,7 +58,7 @@ class ResourceDownloadController extends BaseController
{
try {
/** @var Filesystem $fs */
$fs = $this->container->get('oneup_flysystem.courses_filesystem');
$fs = $this->container->get('oneup_flysystem.resources_filesystem');
$file = $request->get('file');
$path = $course.'/document/'.$file;
@ -117,7 +117,7 @@ class ResourceDownloadController extends BaseController
{
try {
/** @var Filesystem $fs */
$fs = $this->container->get('oneup_flysystem.courses_filesystem');
$fs = $this->container->get('oneup_flysystem.resources_filesystem');
$file = $request->get('file');
$path = $course.'/document/'.$file;

@ -15,7 +15,7 @@
<input id="fileupload"
type="file"
name="files[]"
data-url="{{ oneup_uploader_endpoint('courses') }}"
data-url="{{ oneup_uploader_endpoint('resource') }}"
multiple
/>
{% endblock %}

Loading…
Cancel
Save