Re: runserver MIME types on Windows

2020-09-25 Thread Jacob Rief
Hi Peter,
as a co-maintainer of django-filer I experienced similar problems. Often 
you can not rely on the MIME-type provided by the uploading browser.

In your situation, one possible solution would be to guess the MIME-type by 
looking at the magic header of the received file.
For this purpose you can use the filetype 
-library.

– Jacob

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/37df5e10-e0fa-4694-a933-93dddbcedf0dn%40googlegroups.com.


Re: runserver MIME types on Windows

2020-09-25 Thread Carlton Gibson
Hi Peter. 

There's a note already for this exact issue in the staticfiles docs. 
https://docs.djangoproject.com/en/3.1/ref/contrib/staticfiles/#django.contrib.staticfiles.views.serve

It mentions Red-Hat and Debian, but it would be reasonable to add a pointer 
for Windows users too. 

Beyond that I'm really not sure what we could do. There's no error we could 
catch, and we can't/won't reimplement mimetypes… 

Kind Regards,

Carlton

On Friday, 25 September 2020 at 15:55:54 UTC+2 tari...@gmail.com wrote:

> Hi list,
>
> When developing on Windows I was recently bit by Windows providing wrong 
> MIME type mappings for file names. I filed a ticked for that which has more 
> details [1], but given it was summarily closed as not a bug in Django I 
> wanted to see if there were broader opinions on the matter.
>
> [1] https://code.djangoproject.com/ticket/32041
>
> I don't disagree with the argument that the incorrect behavior isn't 
> really a Django bug (if anything it's a Windows problem), but I don't see a 
> feasible way to make the upstream behavior better either- Python is using 
> the platform-defined mechanism and we're just stuck with it being wrong in 
> some cases.
>
> Given there's evidence that problems like this are not vanishingly rare 
> (based on votes on the Stack Overflow discussion and Go bug linked from the 
> ticket) and it doesn't seem feasible to handle the problem upstream, I 
> think Django sits at a position where some kind of workaround is 
> appropriate.
>
> The simplest way might just be a note in the documentation saying "MIME 
> types on Windows might be wrong, here's how you can fix them," though I 
> feel a better solution might be to specifically call mimetypes.init() on 
> startup with an empty list in order to ignore the system-provided mappings 
> (possibly with a user opt-in for system-provided mappings).
>
> Thoughts on working around Windows problems with the dev server like this?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/1a0bddfe-5a84-4267-864d-311d600dcbbdn%40googlegroups.com.


runserver MIME types on Windows

2020-09-25 Thread Peter Marheine
Hi list,

When developing on Windows I was recently bit by Windows providing wrong 
MIME type mappings for file names. I filed a ticked for that which has more 
details [1], but given it was summarily closed as not a bug in Django I 
wanted to see if there were broader opinions on the matter.

[1] https://code.djangoproject.com/ticket/32041

I don't disagree with the argument that the incorrect behavior isn't really 
a Django bug (if anything it's a Windows problem), but I don't see a 
feasible way to make the upstream behavior better either- Python is using 
the platform-defined mechanism and we're just stuck with it being wrong in 
some cases.

Given there's evidence that problems like this are not vanishingly rare 
(based on votes on the Stack Overflow discussion and Go bug linked from the 
ticket) and it doesn't seem feasible to handle the problem upstream, I 
think Django sits at a position where some kind of workaround is 
appropriate.

The simplest way might just be a note in the documentation saying "MIME 
types on Windows might be wrong, here's how you can fix them," though I 
feel a better solution might be to specifically call mimetypes.init() on 
startup with an empty list in order to ignore the system-provided mappings 
(possibly with a user opt-in for system-provided mappings).

Thoughts on working around Windows problems with the dev server like this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/94460aec-2452-4b59-a0fc-dfb9446884e1n%40googlegroups.com.