Skip to content

Guess extension from detected mime type to add to filename

partial workaround for #1167 (closed) to enable downloading raw contents with extensions under the /content/raw/ endpoint.

If mime types identified as "text/*" other than "text/plain", suggesting the programming language in the content is potentially detected, guess the file extension using mimetypes library and add it to filename.

This way, when users download raw contents using "Save Page As" will get a file with extension, making it easier to inspect the content locally.

Limitations include mime types guessed wrong or not detected.

Future work plan: get content's filename by the hash value.

Test Plan

edit test cases to match changed raw content filename proposed in this diff.


Migrated from D1369 (view on Phabricator)

Merge request reports