collective.updatemimetype
This Plone add-on can be used to update broken mimetypes of Blob fields.
When a file or an image is uploaded to a Blob field, its mimetype is computed based on information from the mimetypes_registry.
If that registry misses some information, the computed mimetype can be wrong or too general.
For instance, prior to version 2.0.7 of Products.MimetypeRegistry, the default mimetypes_registry of a Plone portal did not know of OpenXML mimetypes. Those files would get application/zip mimetype instead of their proper mimetypes.
As computation of mimetype happens only at load time, upgrading Products.MimetypeRegistry is not enough to fix broken mimetypes.
The function collective.updatemimetype.migrate walks over content, looks for blob fields that would get different mimetype if they would be uploaded again, and updates those field mimetypes. It can be called from a GenericSetup upgrade step with:
from collective.updatemimetype import migrate migrate(portal)
If you want to limit migration to specific content items, you can pass a query argument to the migrate function. For instance, while the code above updates both File and Image content items of a default Plone site, the code below would only update File content items:
from collective.updatemimetype import migrate
catalog_query = {'portal_type': 'File'}
migrate(portal, catalog_query)
There is also a view registered on the portal. Call it with:
http://my_domain/my_portal/updatemimetype
The view can also be called with a query parameter. To limit update to File items, call the view with:
http://my_domain/my_portal/updatemimetype?query.portal_type:record:string=File
Contributors
Godefroid Chapelle, gotcha@bubblenet.be, funded by KULeuven
Changelog
0.1.2 (2015-07-06)
Fix limiting update to the results of a catalog query. And document how to do it. [gotcha]
0.1.1 (2015-06-30)
Fix classifier [gotcha]
0.1 (2015-06-29)
Initial release. [gotcha]
Metadata
Release files for collective.updatemimetype 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| collective.updatemimetype-0.1.2.zip | 27.9 kB | Without provenance | Details for collective.updatemimetype-0.1.2.zip |
Release files / collective.updatemimetype-0.1.2.zip
| Download URL | collective.updatemimetype-0.1.2.zip |
|---|---|
| Size | 27.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e846dfa9bc01a2cea65349933d91a77cde09baf7d0b7dcb38970ca4b42acf19
|
|
BLAKE2b-256 checksum How to use checksums |
c1524ea82bbe44d6cfc40d539aee7e401961ea6b393b331304773eb73ca2703f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for collective.updatemimetype 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.