Closed Gilaberte closed 4 years ago
sonata-project/admin-bundle 3.71.1 3.75.0 The missing Symfony Admin Generator sonata-project/block-bundle 3.20.0 4.3.0 Symfony SonataBlockBundle sonata-project/cache 2.0.1 2.0.1 Cache library sonata-project/datagrid-bundle 2.5.0 3.2.0 Symfony SonataDatagridBundle sonata-project/doctrine-extensions 1.8.0 1.9.1 Doctrine2 behavioral extensions sonata-project/doctrine-orm-admin-bundle 3.21.0 3.22.0 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle sonata-project/easy-extends-bundle 2.5.0 2.5.0 Symfony SonataEasyExtendsBundle sonata-project/exporter 2.3.0 2.3.0 Lightweight Exporter library sonata-project/form-extensions 1.5.0 1.6.0 Symfony form extensions sonata-project/formatter-bundle 4.2.0 4.2.0 Symfony SonataFormatterBundle sonata-project/media-bundle 3.25.0 3.27.0 Symfony SonataMediaBundle sonata-project/twig-extensions 1.3.1 1.4.1 Sonata twig extensions sonata-project/user-bundle 4.6.0 4.8.0 Symfony SonataUserBundle
symfony/asset v4.4.13 v5.1.5 Symfony Asset Component symfony/cache v5.1.5 v5.1.5 Symfony Cache component with PSR-6, PSR-16, and tags symfony/cache-contracts v2.2.0 v2.2.0 Generic abstractions related to caching symfony/config v4.4.13 v5.1.5 Symfony Config Component symfony/console v4.4.13 v5.1.5 Symfony Console Component symfony/debug v4.4.13 v4.4.13 Symfony Debug Component symfony/debug-bundle v4.4.11 v5.1.5 Symfony DebugBundle symfony/dependency-injection v4.4.13 v5.1.5 Symfony DependencyInjection Component symfony/deprecation-contracts v2.2.0 v2.2.0 A generic function and convention to trigger deprecation notices symfony/doctrine-bridge v4.4.13 v5.1.5 Symfony Doctrine Bridge symfony/error-handler v4.4.13 v5.1.5 Symfony ErrorHandler Component symfony/event-dispatcher v4.4.13 v5.1.5 Symfony EventDispatcher Component symfony/event-dispatcher-contracts v1.1.9 v2.2.0 Generic abstractions related to dispatching event symfony/expression-language v4.4.13 v5.1.5 Symfony ExpressionLanguage Component symfony/filesystem v4.4.13 v5.1.5 Symfony Filesystem Component symfony/finder v4.4.13 v5.1.5 Symfony Finder Component symfony/form v4.4.13 v5.1.5 Symfony Form Component symfony/framework-bundle v4.4.11 v5.1.5 Symfony FrameworkBundle symfony/http-foundation v4.4.13 v5.1.5 Symfony HttpFoundation Component symfony/http-kernel v4.4.13 v5.1.5 Symfony HttpKernel Component symfony/inflector v5.1.5 v5.1.5 Symfony Inflector Component symfony/intl v5.1.5 v5.1.5 A PHP replacement layer for the C intl extension that includes additional data from the ICU library. symfony/mime v5.1.5 v5.1.5 A library to manipulate MIME messages symfony/monolog-bridge v5.1.5 v5.1.5 Symfony Monolog Bridge symfony/monolog-bundle v3.5.0 v3.5.0 Symfony MonologBundle symfony/options-resolver v4.4.13 v5.1.5 Symfony OptionsResolver Component symfony/polyfill-ctype v1.18.1 v1.18.1 Symfony polyfill for ctype functions symfony/polyfill-iconv v1.18.1 v1.18.1 Symfony polyfill for the Iconv extension symfony/polyfill-intl-grapheme v1.18.1 v1.18.1 Symfony polyfill for intl's grapheme_* functions symfony/polyfill-intl-icu v1.18.1 v1.18.1 Symfony polyfill for intl's ICU-related data and classes symfony/polyfill-intl-idn v1.18.1 v1.18.1 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions symfony/polyfill-intl-normalizer v1.18.1 v1.18.1 Symfony polyfill for intl's Normalizer class and related functions symfony/polyfill-mbstring v1.18.1 v1.18.1 Symfony polyfill for the Mbstring extension symfony/polyfill-php70 v1.18.1 v1.18.1 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions symfony/polyfill-php72 v1.18.1 v1.18.1 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions symfony/polyfill-php73 v1.18.1 v1.18.1 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions symfony/polyfill-php80 v1.18.1 v1.18.1 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions symfony/process v5.1.5 v5.1.5 Symfony Process Component symfony/property-access v4.4.13 v5.1.5 Symfony PropertyAccess Component symfony/routing v4.4.13 v5.1.5 Symfony Routing Component symfony/security-acl v3.1.0 v3.1.0 Symfony Security Component - ACL (Access Control List) symfony/security-bundle v4.4.13 v5.1.5 Symfony SecurityBundle symfony/security-core v4.4.13 v5.1.5 Symfony Security Component - Core Library symfony/security-csrf v4.4.13 v5.1.5 Symfony Security Component - CSRF Library symfony/security-guard v4.4.13 v5.1.5 Symfony Security Component - Guard symfony/security-http v4.4.13 v5.1.5 Symfony Security Component - HTTP Integration symfony/serializer v4.4.11 v5.1.5 Symfony Serializer Component symfony/service-contracts v2.2.0 v2.2.0 Generic abstractions related to writing services symfony/stopwatch v5.1.5 v5.1.5 Symfony Stopwatch Component symfony/string v5.1.5 v5.1.5 Symfony String component symfony/swiftmailer-bundle v3.4.0 v3.4.0 Symfony SwiftmailerBundle symfony/templating v4.4.13 v5.1.5 Symfony Templating Component symfony/translation v4.4.13 v5.1.5 Symfony Translation Component symfony/translation-contracts v2.2.0 v2.2.0 Generic abstractions related to translation symfony/twig-bridge v4.4.13 v5.1.5 Symfony Twig Bridge symfony/twig-bundle v4.4.11 v5.1.5 Symfony TwigBundle symfony/validator v4.4.13 v5.1.5 Symfony Validator Component symfony/var-dumper v5.1.5 v5.1.5 Symfony mechanism for exploring and dumping PHP variables symfony/var-exporter v5.1.5 v5.1.5 A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code symfony/web-profiler-bundle v4.4.11 v5.1.5 Symfony WebProfilerBundle symfony/yaml v4.4.13 v5.1.5 Symfony Yaml Component
PHP 7.3.22-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Sep 9 2020 06:46:12) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.22, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.22-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
I have a custom provider
sonata.media.provider.private: class: Sonata\MediaBundle\Provider\FileProvider tags: - { name: sonata.media.provider } arguments: - 'sonata.media.provider.private' - '@hospital.app.filesystem' - '@sonata.media.cdn.server' - '@sonata.media.generator.default' - '@sonata.media.thumbnail.format' - ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'xlsm', 'xltx', 'zip', 'rar']
and this context:
private: download: strategy: sonata.media.security.public_strategy mode: http providers: - sonata.media.provider.private
I am trying download a file with extension .doc of the next way:
->add('files', MediaType::class, [ 'context' => 'private', 'provider' => 'sonata.media.provider.private', 'template' => 'sonata/list/medias_path.html.twig', ])
medias_path.html.twig:
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %} {% block field %} {% for file in object.files %} {% if file %} <p> <a href="{{ path('sonata_media_download', {'id': file|sonata_urlsafeid }) }}" target="_blank" download><span class="glyphicon glyphicon-download"></span> {{ file.name }}</a> </p> {% endif %} {% endfor %} {% endblock %}
The problem is that when I download the file, the mime type is octet-stream and I can't open the file. The file in the server has the mime type application/msword, so I think the problem occurs in the download.
The response has the headers correctly:
array(2) { ["Content-Type"]=> string(18) "application/msword" ["Content-Disposition"]=> string(33) "attachment; filename="sample.doc"" }
Can you help me?
Waiting for your news.
Best regards
Hi!
The bug was in my code. I close the issue
Thank you for the notice.
Sonata packages
Symfony packages
PHP version
Subject
I have a custom provider
and this context:
I am trying download a file with extension .doc of the next way:
medias_path.html.twig:
The problem is that when I download the file, the mime type is octet-stream and I can't open the file. The file in the server has the mime type application/msword, so I think the problem occurs in the download.
The response has the headers correctly:
Can you help me?
Waiting for your news.
Best regards