Closed simbu-g2t closed 5 years ago
Hello @simbu-g2t sorry for the delay. What are you trying to upload? And at this line it tries to get the Provider did you registered it?
How to register the provider? Can you guide me or give the code?
FYI: I'm new to sonata and symfony
It's working if I add the provider(sonata.media.provider.image) at line number 51 in /vendor/silasjoisten/sonata-multiupload-bundle/src/Controller/MultiUploadController.php
like $providerName = $request->query->get('provider','sonata.media.provider.image');
@simbu-g2t So what kind of provider are you trying to use?
sonata_media.yaml
? It's working if I add the provider(sonata.media.provider.image) at line number 51 in
/vendor/silasjoisten/sonata-multiupload-bundle/src/Controller/MultiUploadController.php
like$providerName = $request->query->get('provider','sonata.media.provider.image');
In your snippet you are setting a default for provider
. if there is no query parameter it will use the default. This behaviour is not so graceful. The logic requires a registered provider otherwise the app has no idea how to handle file/image/video etc.
Are you using default "select provider" view from Sonata or are you trying to generate a direkt url to image multi upload?
Currently I'm using direct URL for multiple upload. It is better if we can able to select provider. I don't know how to do that. This is my sonata_media.yaml
# config/packages/sonata_media.yaml
sonata_media:
# if you don't use default namespace configuration
class:
media: App\Application\Sonata\MediaBundle\Entity\Media
gallery: App\Application\Sonata\MediaBundle\Entity\Gallery
gallery_has_media: App\Application\Sonata\MediaBundle\Entity\GalleryHasMedia
db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr it is mandatory to choose one here
default_context: default # you need to set a context
contexts:
default: # the default context is mandatory
providers:
- sonata.media.provider.dailymotion
- sonata.media.provider.youtube
- sonata.media.provider.image
- sonata.media.provider.file
- sonata.media.provider.vimeo
formats:
admin: { width: 100 , height: 100 , quality: 80}
small: { width: 200 , quality: 80}
medium: { width: 3000 , quality: 80}
big: { width: 500 , quality: 70}
blog: # the default context is mandatory
providers:
- sonata.media.provider.image
- sonata.media.provider.file
formats:
admin: { width: 100 , height: 100 , quality: 80}
small: { width: 200 , quality: 80}
medium: { width: 3000 , quality: 80}
big: { width: 500 , quality: 70}
cdn:
server:
path: /uploads/media # http://media.sonata-project.org/
filesystem:
local:
directory: '%kernel.root_dir%/../public/uploads/media'
create: false
@simbu-g2t Okay so you are generating a direct multi upload link to the multi upload action. You need to pass the provider query parameter.
And for the selection of an provider go to the media grid/list view and it should be done automatically when you click on new
bin/console debug:router
command) and create an link to that
But I don't see the provider in that page, Anything need to add in config to see that?
From the step 3, I followed this only
parameters:
sonata.media.admin.media.controller: SilasJoisten\Sonata\MultiUploadBundle\Controller\MultiUploadController
Anything need to do after this?
Do you have a custom provider?
Please read the manual carefully again please you need to do some other things too. You need to override the provider and use a trait.
Maybe see that: https://github.com/silasjoisten/sonata-multiupload-bundle/issues/56#issuecomment-478078904 There is an example for an custom Audio Provider and how to register that
No, I don't have custom provider right now. Currently I resolved with the below code(added provider in query param) in my sonata_admin.yaml. It's working now with direct URL and I removed the provider query from /vendor/silasjoisten/sonata-multiupload-bundle/src/Controller/MultiUploadController.php
# config/packages/sonata_media.yaml
sonata_admin:
title: 'Sonata Admin'
title_logo: images/logo.png
dashboard:
groups:
media:
label: Media
label_catalogue: ~
icon: '<i class="fa fa-image"></i>'
items:
- route: admin_sonata_media_gallery_list
label: Gallery
- route: admin_sonata_media_media_list
label: Media
- route: admin_sonata_media_media_multi_upload
label: Add Multiple Images
route_params:
provider: sonata.media.provider.image
It should be better if I select the provider from media, But I don't know to create a custom provider
Thanks for your help @silasjoisten
Environment
Sonata packages
PHP version
Subject
I've installed and added this route(admin_sonata_media_media_multi_upload) to my admin menu. I got the below error while clicking the menu link (
http://www.example.com/admin/sonata/media/media/multi-upload
)Steps to reproduce
Follow the 3 steps upto adding parameter in config/services.yaml which is explained in this bundle doc
Expected results
Multiple file upload
Actual results
Argument 1 passed to Sonata\AdminBundle\Controller\CRUDController::get() must be of the type string, null given, called in /var/www/html/Project/vendor/silasjoisten/sonata-multiupload-bundle/src/Controller/MultiUploadController.php on line 55