On 5/2/12, Bastian <
bastien....@gmail.com> wrote:
> This happens when trying to upload a file with a filename that is not in
> ascii. In this case I tried éè´´çoöp_iI$.jpg. The strange thing is that
> firefox uploads it but chrome gets the error!
> I know this has been discussed already but the solutions mentioned did not
> work: I tried to change encoding = "ascii" to encoding = "utf-8" in site.py
> then I tried to add export LANG='en_US.UTF-8' and export
> LC_ALL='en_US.UTF-8' in Apache envvars.
> The problem seems to be in the path since it happens at save time and the
> genericpath.py / exists is called to verify the path and returns what
> follows. Any hint is welcome. This is an ubuntu server but it happens also
> on the debian box. Django 1.3.1, python 2.7. The view is a form with
> request.POST that is saved.
>
>
>
> 1.
> 2.
>
> # Does a path exist?
>
> 3.
>
> # This is false for dangling symbolic links on systems that support them.
>
> 4.
>
> def exists(path):
>
> 5.
>
> """Test whether a path exists. Returns False for broken symbolic
> links"""
>
> 6.
>
> try:
>
>
>
> 1.
>
> os.stat(path)
>
> ...
>
>
> 1.
>
> except os.error:
>
> 2.
>
> return False
>
> 3.
>
> return True
>
> 4.
> 5.
> 6.
>
> # This follows symbolic links, so both islink() and isdir() can be true
>
>
> ▼ Local vars <
http://lrdev:8910/looks/create/#>
> VariableValuepath
>
> u'/home/dev/user_media/imgs/\xe9\xe8\xe7o\xf6p_iI.jpg'
You might try reaching in and encoding the filename yourself, to
utf-8, or maybe url encoding it. If this is happening in the admin,
then the easiest approaches may be to use a customized field, or a
field with a customized widget (you can probably sub-class, rather
than going from scratch).
Bill