On Apr 28, 1:40 pm, Yarko Tymciurak <yark...@gmail.com> wrote:
> have you considered filename.abc -->  <uuid>.abc ?if you _always_ store the
> original filename this should be ok.

uuids is how web2y always worked and still does by default.

> Another alternative is to hexify the filename, then the character encoding
> would be irrelevant, and this is simpler than uuid (and decodable), e.g.
>  ABC.abc  ==>  414243.616263

This solves the problem of storing it but not the problem of
downloading a file with a fancy name. We would lose the ability to
search the uploaded files by filename.

> ...there are probably problems with that (e.g. "."?) but maybe that's a
> useful seed for someone to think on.

'.' is not an issue.

> The first problem I see is this (at least) doubles the filename length on
> the filesystem.... which makes uuid a "nicer" solution from that
> perspective.

The uuid was there before and is still there. Yes the field has to be
longer to retain the filename too.

> On Tue, Apr 28, 2009 at 12:55 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > 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