kaliop-uk / ezmigrationbundle

This bundle makes it easy to handle eZPlatform / eZPublish5 content upgrades/migrations
GNU General Public License v2.0
53 stars 81 forks source link

Cannot set mime_type on file upload #147

Open franck-grenier opened 6 years ago

franck-grenier commented 6 years ago

Hello Kaliop, we are uploading css files into ezbinaryfile attributes during a migration. Though we explicitly set the mime type with mime_type: text/css in the migration file, EZ (5.4.10) saves text/plain mime type.

We are doing that kind of migration :

-
    type: content
    mode: update
    match:
        content_id: 31499
    lang: fre-FR
    attributes:
        css:
            path: 'css/css_31499.css'
            mime_type: 'text/css'

Do you have any feedback on this bug ?

Thanks

gggeek commented 6 years ago

Hello.

I tested this, and indeed can reproduce your problem.

I think that this is an error that comes from the ezpublish kernel, specifically in method eZ\Publish\Core\FieldType\BinaryBase\BinaryBaseStorage::storeFieldData() : for version kernel 5.4 around line 114, the mimeType that is sent from the user gets overwritten with the one that is calculated by the IOService. (ref: https://github.com/ezsystems/ezpublish-kernel/blob/v2014.11.8/eZ/Publish/Core/FieldType/BinaryBase/BinaryBaseStorage.php#L114 )

The only fix that I can think of is to replace the BinaryBaseStorage class with a patched one, by setting a different value for parameter %ezpublish.fieldType.ezbinaryfile.externalStorage.class%

gggeek commented 6 years ago

ps: it seems that the same problem still applies to the current ezplatform code, even though the code has been refactored:

https://github.com/ezsystems/ezpublish-kernel/blob/master/eZ/Publish/Core/FieldType/BinaryBase/BinaryBaseStorage.php#L86

gggeek commented 6 years ago

Created ticket: https://jira.ez.no/browse/EZP-28380

gggeek commented 3 years ago

Note that at least the current BinaryBaseStorage does create a coherent value on disk and in the db, as it sets the new mimetype to the field Value. Version v2014.11.8 is even more buggy, as if a user passes in manually a mime-type which differs from what eZ find out on its own, the resulting created field value will be unusable (the file will be stored in the wrong place on disk)

franck-grenier commented 3 years ago

Old one...

Thanks for the update. Most important is that current releases are fixed.

Feel free to close.