it would give more flexibility but would not solve the original
problem.

On Apr 28, 12:41 pm, Álvaro Justen [Turicas] <alvarojus...@gmail.com>
wrote:
> On Tue, Apr 28, 2009 at 12:00 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > There is one issue with my solution.
>
> > If you upload a file filename.abc, it is internally renamed as lots-of-
> > junk--filename.abc
> > and you can download it with
> >http://..../download/lots-of-junk--filename.abc
> > It works on GAE too.
>
> > The problem is that URLs are validated hence filename.abc must be
> > sanitized. I sanitize by replacing any alphanumeric char in filename
> > with one underscore. This is fine for english files. This is not fine
> > with filenames with foreign charsets (like chinese).
>
> > I could replace lots-of-junk--[encoded filename].abc but this may open
> > a big can of worms. If the original file contains special chars, what
> > is the encoding? What if the downloader does not support those chars
> > in the filenames?
>
> > Any advice?
>
> Maybe SQLField can receive a function as an argument, something like this:
>
> def myfunction(f):
>     "get filename and return a customized name to my app"
>     return 'myapp_' + f.split('.')[0] + '.txt'
>
> SQLField('myfile', 'upload', filename=myfunction)
>
> SQLField can verify if filename is a function, string or True/False.
> If it is a function, filename will be function(original-name)
> (function have to return a string), if it is a string, filename will
> be that string and if it is True, web2py uses original name. What do
> you think?
>
> --
>  Álvaro Justen
>  Peta5 - Telecomunicações e Software Livre
>  21 3021-6001 / 9898-0141
>  http://www.peta5.com.br/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to