I have changed this again. Here is how it works....
NO MORE
SQLField('file','update',rememberfilename=True)
NO MORE rememberfilename=True at all
NOW
SQLField('test','upload')
always remembers the filename (話.dat) and encodes it in the stored
filename.
test.file.a0021903cefb.e8a9b12e646174.dat
You probably cannot tell the difference from before.
By default everything works as before BUT if you do
db.mytable.myuploadfield.isttachment=True
the when users visit
http://..../download/test.file.a0021903cefb.e8a9b12e646174.dat
the content disposition will be set to attachment and the filename to
the original filename (話.dat, in unicode, after removing any special
characater that may cause vulnerabilities).
I think this is final.
Please test it.
Massimo
On 28 Apr, 21:41, Iceberg <[email protected]> wrote:
> Maybe we can store the uploaded file on disk as:
> lots-of-junk__encoded-filename.abc
> where:
> lots-of-junk is a unique hash string as web2py currently does.
> encoded-filename.abc can be the original filename encoded by base64
> to make it appears as ascii-char only on disk.
>
> Then when downloading, web2py provides a helper function to change the
> above "lots-of-junk__encoded-filename.abc" back into original
> "filename.abc", so that the download action can set it into the
> Content-Disposition header.
>
> The point here, is assuming the uploaded filename.abc is in utf8
> encoding (the de-facto nowaday standard) or in locale encoding, even
> when in non-English scenario, and also assuming this encoding can be
> properly handled by browser.
>
> On Apr29, 7:26am, mdipierro <[email protected]> wrote:
>
> > I found this which answers some of my questions
>
> >http://stackoverflow.com/questions/93551/how-to-encode-the-filename-p...
>
> > On 28 Apr, 14:30, Yarko Tymciurak <[email protected]> wrote:
>
> > > or maybe just hexing non-ascii standard characters (leave _something_
> > > readable in _some_ cases)....
> > > would this work on latin character sets?
>
> > > I mean would 'a' anywhere be encoded as '0x61'?
>
> > > If so, that might be a human-useful thing.
>
> > > 2009/4/28 mdipierro <[email protected]>
>
> > > > Let's say I upload a file called 漢.dat from a windows machine, how do
> > > > I download it from a Unix machine? I just do not know different
> > > > browsers and
> > > > OSs will handle it and it may cause vulnerabilities. Anyway, I like
> > > > the idea of hexing and it probably better than the current solution. I
> > > > will try it later.
>
> > > > Massimo
>
> > > > On Apr 28, 2:14 pm, Yarko Tymciurak <[email protected]> wrote:
> > > > > > 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.
>
> > > > > Not if you ALWAYS store by uploaded filename, and have the stored
> > > > > name as
> > > > a
> > > > > field for retrieval only...
>
> > > > > Maybe I don't see the problem here...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---