Re: restrict downloading files based on user-permission

2010-11-22 Thread patrickk
here´s a snippet which shows an implementation: http://djangosnippets.org/snippets/1710/ however, the only cross-browser solution I´ve come across is the one I ´ve posted above. regards, patrick On 22 Nov., 16:40, David De La Harpe Golden wrote: > Looked into this a bit (will undoubtedly bite u

Re: restrict downloading files based on user-permission

2010-11-22 Thread David De La Harpe Golden
Looked into this a bit (will undoubtedly bite us soon): On 22/11/10 13:54, Torsten Bronger wrote: > Is there a standard at all for how non-ASCII in the header field > "Content-Disposition" is supposed to be encoded? The rfc5987 [1] based filename*=UTF-8''bl%c3%a4h mechanism very recently exists,

Re: restrict downloading files based on user-permission

2010-11-22 Thread Torsten Bronger
Hallöchen! patrickk writes: > well ... yes, but if someond uploads "äöü.PDF" I want the user to > download "äöü.PDF" again ... and not > %C3%83%C2%A4%C3%83%C2%B6%C3%83%C2%BC.PDF. > > did you test your code with IE7/IE8? I just did and the name of > the downloaded file differs from the upload. Ch

Re: restrict downloading files based on user-permission

2010-11-21 Thread Łukasz Rekucki
I'm guessing that your original problem was that HTTP headers can only contain ASCII characters. To have a UTF-8 encoded name, you should use percent-encoding. I'm using this code on production site: quoted_name = urllib.quote(file.name.encode('utf-8')) response['Content-Disposition'] = 'a

Re: restrict downloading files based on user-permission

2010-11-21 Thread patrickk
well ... yes, but if someond uploads "äöü.PDF" I want the user to download "äöü.PDF" again ... and not %C3%83%C2%A4%C3%83%C2%B6%C3%83%C2%BC.PDF. did you test your code with IE7/IE8? I just did and the name of the downloaded file differs from the upload. regards, patrick On 21 Nov., 20:39, Łukasz

restrict downloading files based on user-permission

2010-11-21 Thread patrickk
I need to serve media-files uploaded by users, but only the user who uploaded a file should be able to download that file again. therefore, I need to check whether the currently logged-in user is the creator of that file (ok, that´s easy with using a view). – of course, serving the media-file via

Re: restrict downloading files based on user-permission

2010-11-21 Thread patrickk
just for the records ... it seems to work when filename is not defined with response["Content-Disposition"] = "attachment; filename=äöü &%%%.pdf" instead just use response["Content-Disposition"] = "attachment" and add the filename to the URL, e.g. /user/downloads/15/äöü &.pdf where 15 is the o