On Thursday, November 3, 2011 3:27:35 AM UTC-4, lucas wrote:
>
> https://localhost/iquanta1/main/dl/myfile.pdf
>
I assume myfile.pdf is the *original* filename. That won't work. You have
to give it the new filename, which includes the table name and field name
of the upload field. You typically get that via a select from the db (e.g.,
file = db.table[id].field, where 'field' is the upload field name).
> items = re.compile('(?P<table>.*?)\.(?P<field>.*?)\..*').match(name)
>
That regex is attempting to extract the table and field names from the
beginning of the new filename. It's not working in your case because you're
using the old filename.
> also, looking at the code, it looks like it downloads the contents of
> the file from the actual database and not from uploads, is that
> correct? if so, it is only using uploads for the encoding of the
> filename, correct?
>
No, by default, it stores the file on the filesystem. The upload field only
stores the new filename. You can store the file itself in a separate blob
field in the database by specifying the name of that blob field as the
'uploadfield' argument to the upload field, but that is not the default
behavior
(see http://web2py.com/book/default/chapter/11#Upload-Files-in-Database).
Anthony