[Zope-dev] inconsistent mimetype assignment for uploaded files

Andreas Jung lists at andreas-jung.com
Thu Sep 30 03:45:44 EDT 2004



--On Donnerstag, 30. September 2004 9:36 Uhr +0200 Jan-Wijbrand Kolman 
<jw at infrae.com> wrote:
>
> def _get_content_type(self, file, body, id, content_type=None):
>      """
>      Order of precedence:
>      1) see if guess_content_type resolves to a mimetype for the
>         filename
>      2) if not use content_type as sent in the headers if
>         available
>      3) else use argument passed in
>      """
>      headers = getattr(file, 'headers', {})
>      content_type = headers.get('content-type', content_type)
>      if type(body) is not type(''):
>          body = body.data
>      name = getattr(file, 'filename', id)
>      content_type, enc = guess_content_type(name, body, content_type)
>      return content_type
>
> Does anyone have an opinion on this? Is the current behaviour
> completely intentional, maybe even according to some specification
> (and thus I should deal with it on the application level)? Should I
> file a collector issue?

Looks like a reasonable solution. If it works be can include the changes 
for Zope 2.8
(maybe Zope 2.7.4).

Andreas



More information about the Zope-Dev mailing list