Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set mime_type on file upload #147

Open
franck-grenier opened this issue Nov 28, 2017 · 5 comments
Open

Cannot set mime_type on file upload #147

franck-grenier opened this issue Nov 28, 2017 · 5 comments

Comments

@franck-grenier
Copy link

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
Copy link
Member

gggeek commented Dec 2, 2017

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
Copy link
Member

gggeek commented Dec 2, 2017

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
Copy link
Member

gggeek commented Dec 2, 2017

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

@gggeek gggeek added the bug label Dec 2, 2017
gggeek pushed a commit that referenced this issue Dec 2, 2017
@gggeek gggeek added upstream bug and removed bug labels Oct 30, 2020
@gggeek
Copy link
Member

gggeek commented Jan 6, 2021

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
Copy link
Author

Old one...

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

Feel free to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants