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

Add support for image/webp to mimetypes package #2002

Merged
merged 1 commit into from
Oct 18, 2024
Merged

Conversation

aron
Copy link
Contributor

@aron aron commented Oct 17, 2024

Fixes PLAT-341

This has only recently been introduced in Python 3.13.0 and is currently inconsistently implemented across different platforms. Confusingly webp is supported in local development on macOS but not when building the docker image of a cog model. This is either because it's not defined in the system mime.types file of the Linux image or because a dev dependency is manually adding it. I've not done the work to fully understand which.

This commit introduces a function called in the init script for the cog package that patches the global mimetypes registry to understand the .webp extension and image/webp mime type. This will be a no-op on systems that already understand the type.

This fixes a bug whereby files with the .webp extension are uploaded to the --upload-url with the incorrect application/octet-stream header.

Note

This needs to be ported over to the main 0.11 branch when accepted.

This has only recently been introduced in Python 3.13.0 and is currently
inconsistently implemented across different platforms. Confusingly webp
is supported in local development on macOS but not when building the
docker image of a cog model. This is either because it's not defined in
the system mime.types file of the Linux image or because a dev
dependency is manually adding it. I've not done the work to fully
understand which.

This commit introduces a function called in the init script for the cog
package that patches the global mimetypes registry to understand the
.webp extension and image/webp mime type. This will be a no-op on
systems that already understand the type.

This fixes a bug whereby files with the .webp extension are uploaded to
the --upload-url with the incorrect application/octet-stream header.
@aron aron merged commit 12d5a4c into async Oct 18, 2024
9 checks passed
@aron aron deleted the async-webp-mimetypes branch October 18, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants