2017 © Pedro Peláez
 

symfony-bundle media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

image

avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  • Wednesday, May 25, 2016
  • by avtonomspb
  • Repository
  • 1 Watchers
  • 1 Stars
  • 56 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Сlient for API SonataMediaBundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle, (*1)

Page bundle: https://github.com/Avtonom/media-storage-client-bundle, (*2)

Run the following in your project root, assuming you have composer set up for your project, (*3)


composer.phar require avtonom/media-storage-client-bundle ~1.2

Switching ~1.2 for the most recent tag., (*4)

Add the bundle to app/AppKernel.php, (*5)


$bundles( ... new Sensio\Bundle\BuzzBundle\SensioBuzzBundle(), new Avtonom\MediaStorageClientBundle\AvtonomMediaStorageClientBundle(), ... );

Configuration options (parameters.yaml):, (*6)

``` yaml, (*7)

parameters: avtonom.media_storage_client: clients: client_name_url: base_url: http://demo.com add_media_url: /app_dev.php/api/providers/sonata.media.provider.url/media client_name_url: base_url: http://demo.com add_media_url: /app_dev.php/api/providers/sonata.media.provider.file/media urls: base_url: http://demo.com get_media_by_reference_full_url: /app_dev.php/api/media/referencefull listener: interfaces: ['Bundle\Model\EntityInterface1', 'Bundle\Model\EntityInterface2'] change_field: my_change_field ignored_domains: ['s.dev.demo.com', 's.prod.demo.com'] client: client_name_url context: context logging_level: 100, (*8)


[Optionally] Configuration bower (\web\bower.json) to file upload:

"blueimp-file-upload-node": "*", (*9)


[Optionally] File js to file upload (for example: \src\Bundle\Resources\views\standard_layout.html.twig): This example uses a library of x-editable (http://vitalets.github.io/x-editable/). ``` twig {% block javascripts %} {{ parent() }} {% javascripts '@AvtonomMediaStorageClientBundle/Resources/public/js/actions.js' %} {% endjavascripts %} {% endblock %}

Use alternative number 1: block to add a reference to the file

``` twig, (*10)

{% if mediaReferenceFull is not empty %} {% set media = media_get(mediaReferenceFull) %} {% if media is ProxyMediaInterface %} {{ media.name }} {% else %} ERROR: file not found {% endif %} {% endif %}   , (*11)


Use the value of the parameters.yaml for the listener: ``` yaml services: avtonom.media_storage_client.listener: class: Avtonom\MediaStorageClientBundle\EventListener\ObjectAddFileListener ... tags: - { name: doctrine.event_listener, event: prePersist, method: run } - { name: doctrine.event_listener, event: preUpdate, method: run }

Use alternative number 1: button to upload the file

``` twig, (*12)

{{ mediaReferenceFull is empty ? 'Add' : 'Update' }}  

Processing in the controller: ``` php public function updateAction(Request $request) { /** @var UploadedFile $file */ $file = $request->files->get('file'); if($file instanceof UploadedFile){ $proxyMedia = $this->get('avtonom.media_storage_client.manager')->sendFile($file, $clientName, $context); return new JsonResponse([ 'media' => $proxyMedia->toArray(), ]); } }

The Versions

25/05 2016

dev-master

9999999-dev https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient

02/02 2016

v1.3.3

1.3.3.0 https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient

19/01 2016

v1.3.2

1.3.2.0 https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient

27/10 2015

v1.3.1

1.3.1.0 https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient

27/10 2015

v1.3.0

1.3.0.0 https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient

23/10 2015

v1.2.0

1.2.0.0 https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient

23/10 2015

v1.1.3

1.1.3.0 https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient

21/10 2015

v1.1.2

1.1.2.0 https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient

21/10 2015

v1.1.1

1.1.1.0 https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient

20/10 2015

v1.1.0

1.1.0.0 https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient

20/10 2015

v0.1.0

0.1.0.0 https://github.com/Avtonom/media-storage-client-bundle

Symfony media client bundle for uploading (sending) files and images to a remote server deployed on SonataMediaBundle

  Sources   Download

MIT

The Requires

 

by Anton U

symfony2 bundle storage sonatamediabundle sonatamediabundleclient mediastorage mediastorageclient